@jals1212/pi-spaces-cli 0.1.0 → 0.2.0
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/CHANGELOG.md +11 -0
- package/README.md +1 -0
- package/dist/cli.js +20 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,17 @@ commands and options and a patch version fixes.
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
+
## 0.2.0
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `pi-space --version` (or `-v`) prints the version.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- An unknown option such as `--bogus` in first place is reported as an unknown
|
|
18
|
+
option with the usage, exit code 2, instead of as an invalid space name.
|
|
19
|
+
|
|
9
20
|
## 0.1.0
|
|
10
21
|
|
|
11
22
|
### Added
|
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ Node 20 or later. The Pi extension `@jals1212/pi-spaces` must be installed in th
|
|
|
18
18
|
| `pi-space <name> [pi args...]` | Starts Pi in that space (`base` for the home Pi starts with). |
|
|
19
19
|
| `pi-space list` | Lists the spaces. A space named `list` can still be opened from the picker. |
|
|
20
20
|
| `pi-space --help` | Shows the usage. |
|
|
21
|
+
| `pi-space --version` | Prints the version. |
|
|
21
22
|
|
|
22
23
|
## Another program that runs Pi
|
|
23
24
|
|
package/dist/cli.js
CHANGED
|
@@ -1,29 +1,41 @@
|
|
|
1
1
|
// The optional `pi-space` command: pick a space and start Pi in it.
|
|
2
2
|
// It only passes `--space <name>`; the extension does the switch, so it never sets PI_CODING_AGENT_DIR.
|
|
3
3
|
import { spawn as nodeSpawn } from "node:child_process";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
4
5
|
import { homedir } from "node:os";
|
|
5
6
|
import { createInterface } from "node:readline";
|
|
6
7
|
import { BASE, listSpaces, spacesDir, validateName } from "@jals1212/pi-spaces/spaces";
|
|
7
8
|
|
|
8
|
-
export const USAGE = `Usage: pi-space [<name> [pi args...] | list | --help]
|
|
9
|
+
export const USAGE = `Usage: pi-space [<name> [pi args...] | list | --help | --version]
|
|
9
10
|
pi-space pick a space and start Pi in it
|
|
10
11
|
pi-space <name> ... start Pi in a space ("base" for the home Pi starts with)
|
|
11
12
|
pi-space list list the spaces
|
|
13
|
+
pi-space --version print the version
|
|
12
14
|
PI_SPACES_COMMAND sets the program to run (default: pi), e.g. "my-launcher --".
|
|
13
15
|
`;
|
|
14
16
|
|
|
17
|
+
/** This package's version; package.json sits one folder above both src/ and dist/. */
|
|
18
|
+
export const VERSION = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
19
|
+
|
|
15
20
|
|
|
16
21
|
|
|
22
|
+
|
|
23
|
+
|
|
17
24
|
|
|
18
25
|
|
|
19
26
|
|
|
20
27
|
|
|
21
28
|
|
|
22
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* `list` is the subcommand, so a space named "list" can only be opened from the picker.
|
|
31
|
+
* A space name never starts with "-", so any other option in first place is unknown, not a name.
|
|
32
|
+
*/
|
|
23
33
|
export function parseCli(args ) {
|
|
24
34
|
const [first, ...rest] = args;
|
|
25
35
|
if (first === undefined) return { kind: "picker" };
|
|
26
36
|
if (first === "--help" || first === "-h") return { kind: "help" };
|
|
37
|
+
if (first === "--version" || first === "-v") return { kind: "version" };
|
|
38
|
+
if (first.startsWith("-")) return { kind: "unknown-option", option: first };
|
|
27
39
|
if (first === "list") return rest.length === 0 ? { kind: "list" } : { kind: "usage" };
|
|
28
40
|
return { kind: "launch", name: first, args: rest };
|
|
29
41
|
}
|
|
@@ -81,6 +93,12 @@ export async function main(argv , io ) {
|
|
|
81
93
|
case "help":
|
|
82
94
|
io.stdout.write(USAGE);
|
|
83
95
|
return io.exit(0);
|
|
96
|
+
case "version":
|
|
97
|
+
io.stdout.write(`${VERSION}\n`);
|
|
98
|
+
return io.exit(0);
|
|
99
|
+
case "unknown-option":
|
|
100
|
+
io.stderr.write(`pi-space: Unknown option "${command.option}".\n${USAGE}`);
|
|
101
|
+
return io.exit(2);
|
|
84
102
|
case "usage":
|
|
85
103
|
io.stderr.write(USAGE);
|
|
86
104
|
return io.exit(2);
|
package/package.json
CHANGED