@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 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
- ### Completion modes: `--runtime` (default) and `--shell`
62
+ ### How completion works
63
63
 
64
- By default, `completion <shell>` emits a a shim that executes itself as `<cli> completion complete -- <commandline>`, allowing it to reuse its own parser. This is slower on average, but allows it to provide native-feeling completions that respect your nitpicky parser options. So long as you keep the startup time of your CLI acceptable, there isn't much of a downside to this.
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
- Alternatively, `completion <shell> --shell` emits a self-contained shell completion script. It can't track line state, so relationship filters like `exclusiveOn`/`isRepeatable` aren't applied. Dynamic generators still call back via `completion generate-suggestions`.
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: in runtime mode it runs in-process, in `--shell` mode it is reached via the hidden `completion generate-suggestions <location>` callback.
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
- /** Allow this option to be supplied multiple times. */
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
- * Generators run by re-invoking the CLI's hidden `completion
180
- * generate-suggestions` command, so `custom` executes in the CLI's own
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;