@ufo-soft/caelus-cli 0.1.0 → 0.1.1
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 +29 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @ufo-soft/caelus-cli
|
|
2
|
+
|
|
3
|
+
A caelus registry as a command-line interface. Each command becomes a subcommand and each parameter
|
|
4
|
+
an option, all derived from the registry, via [commander](https://github.com/tj/commander.js).
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
npm install @ufo-soft/caelus @ufo-soft/caelus-cli
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { cli } from '@ufo-soft/caelus-cli'
|
|
12
|
+
|
|
13
|
+
process.exitCode = await cli(registry, process.argv.slice(2), 'todo')
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
$ todo add --text 'write it down'
|
|
18
|
+
$ todo --help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`cli` resolves to the exit code rather than exiting, so the caller decides what to do with it.
|
|
22
|
+
|
|
23
|
+
- A `string` or `integer` parameter is a required `--name <value>` option; an integer is checked
|
|
24
|
+
before the handler runs.
|
|
25
|
+
- A `boolean` parameter is a `--name` flag, false when absent.
|
|
26
|
+
- An `ok` outcome prints its data, if any: a string as-is, anything else as JSON.
|
|
27
|
+
- A `failed` outcome prints its reason to stderr and exits non-zero.
|
|
28
|
+
|
|
29
|
+
Output goes to `process.stdout` and `process.stderr` unless an `Io` is passed as the fourth argument.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ufo-soft/caelus-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Expose a caelus registry as a command-line interface.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"prepublishOnly": "npm run build"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@ufo-soft/caelus": "^0.1.
|
|
29
|
+
"@ufo-soft/caelus": "^0.1.1",
|
|
30
30
|
"commander": "^15.0.0"
|
|
31
31
|
}
|
|
32
|
-
}
|
|
32
|
+
}
|