@clo4/cli 1.0.0 → 2.0.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/README.md +4 -6
- package/dist/index.d.ts +9 -4
- package/dist/index.js +537 -1013
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +21 -6
- package/dist/testing.js +46 -135
- package/dist/testing.js.map +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -59,13 +59,11 @@ demo completion fish > ~/.config/fish/completions/demo.fish
|
|
|
59
59
|
|
|
60
60
|
Completion describes the whole CLI from the root spec regardless of where the subcommand is placed. Hidden options and subcommands are excluded; persistent options are offered on the descendants that inherit them.
|
|
61
61
|
|
|
62
|
-
###
|
|
62
|
+
### How completion works
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
`completion <shell>` prints a short script. On every Tab, the script runs `<cli> completion complete -- <commandline>`, and the CLI answers using its own parser. Completions therefore follow every parser option and relationship rule (`exclusiveOn`, `isRepeatable`, `dependsOn`, and so on). Each Tab starts the CLI once, so keep its startup fast.
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
In runtime mode, the bash and fish shims pass `--gate-options`, so options are only offered once the word starts with `-` (matching fish/bash convention); zsh omits it and surfaces options as usual. Flip this by editing which shims pass the option.
|
|
66
|
+
The bash and fish scripts pass `--gate-options`, so options are only offered once the word starts with `-`, which is the bash and fish convention. The zsh script leaves it out and offers options as usual.
|
|
69
67
|
|
|
70
68
|
### Argument suggestions
|
|
71
69
|
|
|
@@ -96,4 +94,4 @@ Arguments can declare completion metadata. These are only used for completions,
|
|
|
96
94
|
|
|
97
95
|
- `template` (`"filepaths"` / `"folders"`) completes paths.
|
|
98
96
|
- `suggestions` is a static list (strings or `{ name, description }`).
|
|
99
|
-
- `generators.custom(tokens)` returns dynamic suggestions
|
|
97
|
+
- `generators.custom(tokens)` returns dynamic suggestions. It runs inside the CLI when the shell asks for completions.
|
package/dist/index.d.ts
CHANGED
|
@@ -130,7 +130,12 @@ interface Option {
|
|
|
130
130
|
hidden?: true;
|
|
131
131
|
/** Only allow arguments to be supplied with a separator. */
|
|
132
132
|
requiresSeparator?: true | string;
|
|
133
|
-
/**
|
|
133
|
+
/**
|
|
134
|
+
* Allow this option to be supplied multiple times. `true` allows any number
|
|
135
|
+
* of uses, and a number is the most uses allowed. An option with arguments
|
|
136
|
+
* collects the values from every use, in order. Without arguments, each use
|
|
137
|
+
* adds an empty string, so `count()` returns the number of uses.
|
|
138
|
+
*/
|
|
134
139
|
isRepeatable?: true | number;
|
|
135
140
|
/** Require this option to be supplied before the selected action runs. */
|
|
136
141
|
isRequired?: true;
|
|
@@ -176,9 +181,8 @@ interface Suggestion {
|
|
|
176
181
|
/**
|
|
177
182
|
* Generates dynamic completion suggestions.
|
|
178
183
|
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* process. Completions only — no effect on parsing.
|
|
184
|
+
* `custom` runs inside the CLI when the shell asks it for completions. It only
|
|
185
|
+
* affects completion and has no effect on parsing.
|
|
182
186
|
*/
|
|
183
187
|
interface Generator {
|
|
184
188
|
/** Produce suggestions from the current command-line tokens. */
|
|
@@ -217,6 +221,7 @@ export declare const help: Option;
|
|
|
217
221
|
* the selected command's required arguments.
|
|
218
222
|
*/
|
|
219
223
|
export declare function run(spec: Spec, args?: readonly string[]): Promise<number>;
|
|
224
|
+
/** Print `Error:` and the given values to stderr, separated by spaces. */
|
|
220
225
|
export declare function printError(...strings: unknown[]): void;
|
|
221
226
|
declare const _default: {
|
|
222
227
|
completion: Subcommand;
|