unreleased-cli 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -57,7 +57,7 @@ Commands (type `help <command>` in the shell for the details of each one):
57
57
  - **Admin** (administrators only): `pending`, `proposals`, `comps`, `applications`, `cdn`, `inspect`, `approve`, `reject`, `reverse`, `users`, `sitebans`, `siteunban`
58
58
  - **Fun:** `neofetch`, `fortune`, `juicesay`, `matrix`, `visualizer`, `karaoke`, `wordle`, `heardle`
59
59
  - **Settings:** `set`, `settings`, `termtheme`
60
- - **Shell:** `source`, `alias`, `unalias`, `history`, `echo`, `watch`, `full`, `date`, `clear`, `exit`, `help`
60
+ - **Shell:** `source`, `alias`, `unalias`, `history`, `echo`, `watch`, `full`, `date`, `clear`, `reload`, `exit`, `help`
61
61
  - **Account:** `login`, `logout`, `whoami`, `version`
62
62
 
63
63
  Things that work the same as on the site:
@@ -97,7 +97,7 @@ Music plays through a hidden mpv that the interactive shell starts the first tim
97
97
  - `playlist play <name>`, `playlist shuffle <name>`, `liked play` and `shuffle <era> [count]` replace the queue.
98
98
  - `queue add` and `queue next` add to it. `queue` lists it, and `remove N` / `jump N` change it.
99
99
  - Shuffle, repeat, previous and the end of the queue behave as they do on the site.
100
- - `status` (or `now`) shows the song, a progress bar, the settings and the queue.
100
+ - `status` (or `now`) shows the song, a progress bar, the settings and the queue, and follows along live on a terminal (`q` leaves). `status -1` prints it once, and it does too when piped or run in a script.
101
101
  - `like` and `unlike` with no song act on the one playing.
102
102
 
103
103
  The music stops when you leave the shell, so `unreleased play …` on its own says to open the shell instead. If the shell is killed without a chance to stop mpv (for example the terminal window is closed), mpv quits by itself within about 10 seconds.
@@ -154,6 +154,8 @@ Wordle and Heardle keep their progress, streaks and song lists in `~/.unreleased
154
154
 
155
155
  `full` asks the terminal window to go fullscreen, and to leave again. It sends the xterm request for that, which many terminals ignore (Windows Terminal does), so F11 is the fallback.
156
156
 
157
+ `reload` (or `restart`) closes the shell and starts a fresh one, so a version installed by `update` is the one that runs, and your settings and rc file are read again. It only works in the interactive shell, and music stops.
158
+
157
159
  ## Signing in
158
160
 
159
161
  You can browse the files without an account. To sign in:
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/main.ts
4
+ import { spawnSync } from "node:child_process";
4
5
  import { createInterface as createInterface2 } from "node:readline";
5
6
 
6
7
  // src/config.ts
@@ -82,7 +83,7 @@ function saveSettings(settings) {
82
83
 
83
84
  // src/api.ts
84
85
  var DEFAULT_API = "https://juicewrldapi.com/juicewrld";
85
- var VERSION = "0.1.5";
86
+ var VERSION = "0.1.7";
86
87
  function apiBase() {
87
88
  return (process.env.UNRELEASED_API || loadConfig().api || DEFAULT_API).replace(/\/+$/, "");
88
89
  }
@@ -3813,10 +3814,14 @@ var PLAYER_COMMANDS = [
3813
3814
  name: "status",
3814
3815
  aliases: ["now", "np"],
3815
3816
  group: "Player",
3816
- usage: "status",
3817
- description: "What is playing, plus volume, speed, shuffle, repeat and the queue",
3818
- run: async (_a, sh) => {
3817
+ usage: "status [-1]",
3818
+ description: "What is playing, plus volume, speed, shuffle, repeat and the queue. Live on a terminal (q leaves); -1 prints it once",
3819
+ run: async (args, sh) => {
3819
3820
  const p = playerOf(sh);
3821
+ if (!sh.scripted && canOpenScreen() && args.trim() !== "-1") {
3822
+ await sh.execLine("watch -n 1 status -1");
3823
+ return;
3824
+ }
3820
3825
  const t = p.current;
3821
3826
  const [paused, pos, dur] = await Promise.all([p.paused(), p.position(), p.duration()]);
3822
3827
  sh.print([
@@ -5427,6 +5432,18 @@ ${color.dim(`local ${sh.localDir}`)}`)
5427
5432
  { name: "exit", aliases: ["quit"], group: "Shell", usage: "exit", description: "Leave the shell", run: (_arg, sh) => {
5428
5433
  sh.exiting = true;
5429
5434
  } },
5435
+ {
5436
+ name: "reload",
5437
+ aliases: ["restart"],
5438
+ group: "Shell",
5439
+ usage: "reload",
5440
+ description: "Restart the shell (picks up a new version after update, and re-reads your settings and rc file). Music stops",
5441
+ run: (_a, sh) => {
5442
+ if (!sh.player) fail("reload: only the interactive shell can restart");
5443
+ sh.reloading = true;
5444
+ sh.exiting = true;
5445
+ }
5446
+ },
5430
5447
  {
5431
5448
  name: "help",
5432
5449
  aliases: ["man"],
@@ -5569,6 +5586,8 @@ var Shell = class {
5569
5586
  history;
5570
5587
  aliases;
5571
5588
  exiting = false;
5589
+ /** Leaving to start the shell again (reload). */
5590
+ reloading = false;
5572
5591
  /** The music player; only the interactive shell has one (it stops with it). */
5573
5592
  player = null;
5574
5593
  errors = 0;
@@ -5921,6 +5940,7 @@ ${color.dim("(press Ctrl+C again or type exit to leave)")}
5921
5940
  if (shell.player?.current) process.stdout.write(color.dim("music stopped\n"));
5922
5941
  stopMusic();
5923
5942
  await Promise.race([flushPlays(), new Promise((resolve3) => setTimeout(resolve3, 4e3).unref())]);
5943
+ return shell.reloading;
5924
5944
  }
5925
5945
 
5926
5946
  // src/shims/localStorage.ts
@@ -6032,8 +6052,9 @@ async function main() {
6032
6052
  return 0;
6033
6053
  }
6034
6054
  if (args.length === 0 && process.stdin.isTTY) {
6035
- await startRepl();
6036
- return 0;
6055
+ if (!await startRepl()) return 0;
6056
+ const again = spawnSync(process.execPath, [...process.execArgv, process.argv[1]], { stdio: "inherit" });
6057
+ return again.status ?? 1;
6037
6058
  }
6038
6059
  const shell = new Shell(oneShotPrompter(), false);
6039
6060
  let interrupts = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unreleased-cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "The Unreleased site terminal as a command-line shell",
5
5
  "keywords": [
6
6
  "juice-wrld",