@gunshi/docs 0.29.1 → 0.29.3
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/package.json +3 -3
- package/src/api/context/interfaces/CommandContextParams.md +14 -14
- package/src/api/default/classes/DefaultTranslation.md +1 -1
- package/src/api/default/functions/cli.md +5 -5
- package/src/api/default/index.md +1 -1
- package/src/api/default/interfaces/ArgSchema.md +12 -12
- package/src/api/default/interfaces/ArgToken.md +6 -6
- package/src/api/default/interfaces/CliOptions.md +18 -18
- package/src/api/default/interfaces/Command.md +10 -10
- package/src/api/default/interfaces/CommandContext.md +17 -17
- package/src/api/default/interfaces/CommandContextExtension.md +4 -4
- package/src/api/default/interfaces/CommandEnvironment.md +16 -16
- package/src/api/default/interfaces/GunshiParams.md +2 -2
- package/src/api/default/interfaces/PluginContext.md +2 -2
- package/src/api/default/interfaces/PluginDependency.md +2 -2
- package/src/api/default/interfaces/PluginOptions.md +6 -6
- package/src/api/default/interfaces/PluginWithExtension.md +4 -4
- package/src/api/default/interfaces/PluginWithoutExtension.md +4 -4
- package/src/api/default/interfaces/RenderingOptions.md +3 -3
- package/src/api/default/interfaces/SubCommandable.md +11 -11
- package/src/api/default/type-aliases/ExtendContext.md +1 -1
- package/src/api/generator/functions/generate.md +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gunshi/docs",
|
|
3
3
|
"description": "Documentation for gunshi",
|
|
4
|
-
"version": "0.29.
|
|
4
|
+
"version": "0.29.3",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"mermaid": "^11.12.0",
|
|
51
51
|
"oxc-minify": "^0.97.0",
|
|
52
52
|
"tsx": "^4.21.0",
|
|
53
|
-
"typedoc": "^0.28.
|
|
54
|
-
"typedoc-plugin-markdown": "^4.
|
|
53
|
+
"typedoc": "^0.28.17",
|
|
54
|
+
"typedoc-plugin-markdown": "^4.10.0",
|
|
55
55
|
"typedoc-vitepress-theme": "^1.1.2",
|
|
56
56
|
"vitepress": "^2.0.0-alpha.12",
|
|
57
57
|
"vitepress-plugin-group-icons": "^1.5.5",
|
|
@@ -17,17 +17,17 @@ Parameters of [createCommandContext](../functions/createCommandContext.md)
|
|
|
17
17
|
|
|
18
18
|
| Property | Type | Description |
|
|
19
19
|
| ------ | ------ | ------ |
|
|
20
|
-
| <a id="args"></a> `args?` | `ExtractArgs`\<`G`\> | An arguments of target command |
|
|
21
|
-
| <a id="argv"></a> `argv?` | `string`[] | Original command line arguments |
|
|
22
|
-
| <a id="callmode"></a> `callMode?` | [`CommandCallMode`](../../default/type-aliases/CommandCallMode.md) | Command call mode. |
|
|
23
|
-
| <a id="clioptions"></a> `cliOptions?` | [`CliOptions`](../../default/interfaces/CliOptions.md)\<`G`\> | A command options, which is spicialized from `cli` function |
|
|
24
|
-
| <a id="command"></a> `command?` | `C` | A target command |
|
|
25
|
-
| <a id="commandpath"></a> `commandPath?` | `string`[] | The path of nested sub-commands resolved to reach the current command. |
|
|
26
|
-
| <a id="explicit"></a> `explicit?` | `ArgExplicitlyProvided`\<`ExtractArgs`\<`G`\>\> | Explicitly provided arguments |
|
|
27
|
-
| <a id="extensions"></a> `extensions?` | `E` | Plugin extensions to apply as the command context extension. |
|
|
28
|
-
| <a id="omitted"></a> `omitted?` | `boolean` | Whether the command is omitted |
|
|
29
|
-
| <a id="positionals"></a> `positionals?` | `string`[] | A positionals arguments, which passed to the target command |
|
|
30
|
-
| <a id="rest"></a> `rest?` | `string`[] | A rest arguments, which passed to the target command |
|
|
31
|
-
| <a id="tokens"></a> `tokens?` | [`ArgToken`](../../default/interfaces/ArgToken.md)[] | Argument tokens that are parsed by the `parseArgs` function |
|
|
32
|
-
| <a id="validationerror"></a> `validationError?` | `AggregateError` | Validation error from argument parsing. |
|
|
33
|
-
| <a id="values"></a> `values?` | `V` | A values of target command |
|
|
20
|
+
| <a id="property-args"></a> `args?` | `ExtractArgs`\<`G`\> | An arguments of target command |
|
|
21
|
+
| <a id="property-argv"></a> `argv?` | `string`[] | Original command line arguments |
|
|
22
|
+
| <a id="property-callmode"></a> `callMode?` | [`CommandCallMode`](../../default/type-aliases/CommandCallMode.md) | Command call mode. |
|
|
23
|
+
| <a id="property-clioptions"></a> `cliOptions?` | [`CliOptions`](../../default/interfaces/CliOptions.md)\<`G`\> | A command options, which is spicialized from `cli` function |
|
|
24
|
+
| <a id="property-command"></a> `command?` | `C` | A target command |
|
|
25
|
+
| <a id="property-commandpath"></a> `commandPath?` | `string`[] | The path of nested sub-commands resolved to reach the current command. |
|
|
26
|
+
| <a id="property-explicit"></a> `explicit?` | `ArgExplicitlyProvided`\<`ExtractArgs`\<`G`\>\> | Explicitly provided arguments |
|
|
27
|
+
| <a id="property-extensions"></a> `extensions?` | `E` | Plugin extensions to apply as the command context extension. |
|
|
28
|
+
| <a id="property-omitted"></a> `omitted?` | `boolean` | Whether the command is omitted |
|
|
29
|
+
| <a id="property-positionals"></a> `positionals?` | `string`[] | A positionals arguments, which passed to the target command |
|
|
30
|
+
| <a id="property-rest"></a> `rest?` | `string`[] | A rest arguments, which passed to the target command |
|
|
31
|
+
| <a id="property-tokens"></a> `tokens?` | [`ArgToken`](../../default/interfaces/ArgToken.md)[] | Argument tokens that are parsed by the `parseArgs` function |
|
|
32
|
+
| <a id="property-validationerror"></a> `validationError?` | `AggregateError` | Validation error from argument parsing. |
|
|
33
|
+
| <a id="property-values"></a> `values?` | `V` | A values of target command |
|
|
@@ -49,7 +49,7 @@ Run the command.
|
|
|
49
49
|
|
|
50
50
|
`Promise`\<`string` \| `undefined`\>
|
|
51
51
|
|
|
52
|
-
A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#usagesilent) option, it will return rendered usage string.
|
|
52
|
+
A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#property-usagesilent) option, it will return rendered usage string.
|
|
53
53
|
|
|
54
54
|
## Call Signature
|
|
55
55
|
|
|
@@ -81,7 +81,7 @@ Run the command.
|
|
|
81
81
|
|
|
82
82
|
`Promise`\<`string` \| `undefined`\>
|
|
83
83
|
|
|
84
|
-
A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#usagesilent) option, it will return rendered usage string.
|
|
84
|
+
A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#property-usagesilent) option, it will return rendered usage string.
|
|
85
85
|
|
|
86
86
|
## Call Signature
|
|
87
87
|
|
|
@@ -113,7 +113,7 @@ Run the command.
|
|
|
113
113
|
|
|
114
114
|
`Promise`\<`string` \| `undefined`\>
|
|
115
115
|
|
|
116
|
-
A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#usagesilent) option, it will return rendered usage string.
|
|
116
|
+
A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#property-usagesilent) option, it will return rendered usage string.
|
|
117
117
|
|
|
118
118
|
## Call Signature
|
|
119
119
|
|
|
@@ -144,7 +144,7 @@ Run the command.
|
|
|
144
144
|
|
|
145
145
|
`Promise`\<`string` \| `undefined`\>
|
|
146
146
|
|
|
147
|
-
A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#usagesilent) option, it will return rendered usage string.
|
|
147
|
+
A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#property-usagesilent) option, it will return rendered usage string.
|
|
148
148
|
|
|
149
149
|
## Call Signature
|
|
150
150
|
|
|
@@ -177,4 +177,4 @@ prevent proper type inference for more specific command types.
|
|
|
177
177
|
|
|
178
178
|
`Promise`\<`string` \| `undefined`\>
|
|
179
179
|
|
|
180
|
-
A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#usagesilent) option, it will return rendered usage string.
|
|
180
|
+
A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#property-usagesilent) option, it will return rendered usage string.
|
package/src/api/default/index.md
CHANGED
|
@@ -113,7 +113,7 @@ Re-exports [lazyWithTypes](../definition/functions/lazyWithTypes.md)
|
|
|
113
113
|
| [CommandLoader](type-aliases/CommandLoader.md) | Command loader. |
|
|
114
114
|
| [CommandRunner](type-aliases/CommandRunner.md) | Command runner. |
|
|
115
115
|
| [DefaultGunshiParams](type-aliases/DefaultGunshiParams.md) | Default Gunshi parameters. |
|
|
116
|
-
| [ExtendContext](type-aliases/ExtendContext.md) | Extend command context type. This type is used to extend the command context with additional properties at [`CommandContext.extensions`](interfaces/CommandContext.md#extensions). |
|
|
116
|
+
| [ExtendContext](type-aliases/ExtendContext.md) | Extend command context type. This type is used to extend the command context with additional properties at [`CommandContext.extensions`](interfaces/CommandContext.md#property-extensions). |
|
|
117
117
|
| [GunshiParamsConstraint](type-aliases/GunshiParamsConstraint.md) | Generic constraint for command-related types. |
|
|
118
118
|
| [LazyCommand](type-aliases/LazyCommand.md) | Lazy command interface. |
|
|
119
119
|
| [OnPluginExtension](type-aliases/OnPluginExtension.md) | Plugin extension callback, which is called when the plugin is extended with `extension` option. |
|
|
@@ -44,15 +44,15 @@ const schema: ArgSchema = {
|
|
|
44
44
|
|
|
45
45
|
| Property | Type | Description |
|
|
46
46
|
| ------ | ------ | ------ |
|
|
47
|
-
| <a id="choices"></a> `choices?` | `string`[] \| readonly `string`[] | Array of allowed string values for enum-type arguments. Required when `type: 'enum'`. The argument value must be one of these choices, otherwise an `ArgResolveError` with type 'type' will be thrown. Supports both mutable arrays and readonly arrays for type safety. **Example** Enum choices: `{ logLevel: { type: 'enum', choices: ['debug', 'info', 'warn', 'error'] as const, default: 'info', description: 'Logging verbosity level' }, format: { type: 'enum', choices: ['json', 'yaml', 'toml'], description: 'Output format' } }` |
|
|
48
|
-
| <a id="conflicts"></a> `conflicts?` | `string` \| `string`[] | Names of other options that conflict with this option. When this option is used together with any of the conflicting options, an `ArgResolveError` with type 'conflict' will be thrown. Conflicts only need to be defined on one side - if option A defines a conflict with option B, the conflict is automatically detected when both are used, regardless of whether B also defines a conflict with A. Supports both single option name or array of option names. Option names must match the property keys in the schema object exactly (no automatic conversion between camelCase and kebab-case). **Examples** Single conflict (bidirectional definition): `{ summer: { type: 'boolean', conflicts: 'autumn' // Cannot use --summer with --autumn }, autumn: { type: 'boolean', conflicts: 'summer' // Can define on both sides for clarity } }` Single conflict (one-way definition): `{ summer: { type: 'boolean', conflicts: 'autumn' // Only defined on summer side }, autumn: { type: 'boolean' // No conflicts defined, but still cannot use with --summer } } // Usage: --summer --autumn will throw error // Error: "Optional argument '--summer' conflicts with '--autumn'"` Multiple conflicts: `{ port: { type: 'number', conflicts: ['socket', 'pipe'], // Cannot use with --socket or --pipe description: 'TCP port number' }, socket: { type: 'string', conflicts: ['port', 'pipe'], // Cannot use with --port or --pipe description: 'Unix socket path' }, pipe: { type: 'string', conflicts: ['port', 'socket'], // Cannot use with --port or --socket description: 'Named pipe path' } } // These three options are mutually exclusive` With kebab-case conversion: `{ summerSeason: { type: 'boolean', toKebab: true, // Accessible as --summer-season conflicts: 'autumnSeason' // Must use property key, not CLI name }, autumnSeason: { type: 'boolean', toKebab: true // Accessible as --autumn-season } } // Error: "Optional argument '--summer-season' conflicts with '--autumn-season'"` |
|
|
49
|
-
| <a id="default"></a> `default?` | `string` \| `number` \| `boolean` | Default value used when the argument is not provided. The type must match the argument's `type` property: - `string` type: string default - `boolean` type: boolean default - `number` type: number default - `enum` type: must be one of the `choices` values - `positional`/`custom` type: any appropriate default **Example** Default values by type: `{ host: { type: 'string', default: 'localhost' // string default }, verbose: { type: 'boolean', default: false // boolean default }, port: { type: 'number', default: 8080 // number default }, level: { type: 'enum', choices: ['low', 'high'], default: 'low' // must be in choices } }` |
|
|
50
|
-
| <a id="description"></a> `description?` | `string` | Human-readable description of the argument's purpose. Used for help text generation and documentation. Should be concise but descriptive enough to understand the argument's role. **Example** Descriptive help text: `{ config: { type: 'string', description: 'Path to configuration file' }, timeout: { type: 'number', description: 'Request timeout in milliseconds' } }` |
|
|
51
|
-
| <a id="metavar"></a> `metavar?` | `string` | Display name hint for help text generation. Provides a meaningful type hint for the argument value in help output. Particularly useful for `type: 'custom'` arguments where the type name would otherwise be unhelpful. **Example** Metavar usage: `{ port: { type: 'custom', parse: (v: string) => parseInt(v, 10), metavar: 'integer', description: 'Port number (1-65535)' } } // Help output: --port <integer> Port number (1-65535)` |
|
|
52
|
-
| <a id="multiple"></a> `multiple?` | `true` | Allows the argument to accept multiple values. When `true`, the resolved value becomes an array. For options: can be specified multiple times (--tag foo --tag bar) For positional: collects remaining positional arguments Note: Only `true` is allowed (not `false`) to make intent explicit. **Example** Multiple values: `{ tags: { type: 'string', multiple: true, // --tags foo --tags bar → ['foo', 'bar'] description: 'Tags to apply' }, files: { type: 'positional', multiple: true // Collects all remaining positional args } }` |
|
|
53
|
-
| <a id="negatable"></a> `negatable?` | `boolean` | Enables negation for boolean arguments using `--no-` prefix. When `true`, allows users to explicitly set the boolean to `false` using `--no-option-name`. When `false` or omitted, only positive form is available. Only applicable to `type: 'boolean'` arguments. **Example** Negatable boolean: `{ color: { type: 'boolean', negatable: true, default: true, description: 'Enable colorized output' } // Usage: --color (true), --no-color (false) }` |
|
|
54
|
-
| <a id="parse"></a> `parse?` | (`value`) => `any` | Custom parsing function for `type: 'custom'` arguments. Required when `type: 'custom'`. Receives the raw string value and must return the parsed result. Should throw an Error (or subclass) if parsing fails. The function's return type becomes the resolved argument type. **Throws** Error or subclass when value is invalid **Example** Custom parsing functions: `{ config: { type: 'custom', parse: (value: string) => { try { return JSON.parse(value) // Parse JSON config } catch { throw new Error('Invalid JSON configuration') } }, description: 'JSON configuration object' }, date: { type: 'custom', parse: (value: string) => { const date = new Date(value) if (isNaN(date.getTime())) { throw new Error('Invalid date format') } return date } } }` |
|
|
55
|
-
| <a id="required"></a> `required?` | `boolean` | Marks the argument as required. When `true`, the argument must be provided by the user. If missing, an `ArgResolveError` with type 'required' will be thrown. Note: Only `true` is allowed (not `false`) to make intent explicit. **Example** Required arguments: `{ input: { type: 'string', required: true, // Must be provided: --input file.txt description: 'Input file path' }, source: { type: 'positional', required: true // First positional argument must exist } }` |
|
|
56
|
-
| <a id="short"></a> `short?` | `string` | Single character alias for the long option name. As example, allows users to use `-x` instead of `--extended-option`. Only valid for non-positional argument types. **Example** Short alias usage: `{ verbose: { type: 'boolean', short: 'v' // Enables both --verbose and -v }, port: { type: 'number', short: 'p' // Enables both --port 3000 and -p 3000 } }` |
|
|
57
|
-
| <a id="tokebab"></a> `toKebab?` | `true` | Converts the argument name from camelCase to kebab-case for CLI usage. When `true`, a property like `maxCount` becomes available as `--max-count`. This allows [CAC](https://github.com/cacjs/cac) user-friendly property names while maintaining CLI conventions. Can be overridden globally with `resolveArgs({ toKebab: true })`. Note: Only `true` is allowed (not `false`) to make intent explicit. **Example** Kebab-case conversion: `{ maxRetries: { type: 'number', toKebab: true, // Accessible as --max-retries description: 'Maximum retry attempts' }, enableLogging: { type: 'boolean', toKebab: true // Accessible as --enable-logging } }` |
|
|
58
|
-
| <a id="type"></a> `type` | `"string"` \| `"number"` \| `"boolean"` \| `"positional"` \| `"enum"` \| `"custom"` | Type of the argument value. - `'string'`: Text value (default if not specified) - `'boolean'`: `true`/`false` flag (can be negatable with `--no-` prefix) - `'number'`: Numeric value (parsed as integer or float) - `'enum'`: One of predefined string values (requires `choices` property) - `'positional'`: Non-option argument by position - `'custom'`: Custom parsing with user-defined `parse` function **Example** Different argument types: `{ name: { type: 'string' }, // --name value verbose: { type: 'boolean' }, // --verbose or --no-verbose port: { type: 'number' }, // --port 3000 level: { type: 'enum', choices: ['debug', 'info'] }, file: { type: 'positional' }, // first positional arg config: { type: 'custom', parse: JSON.parse } }` |
|
|
47
|
+
| <a id="property-choices"></a> `choices?` | `string`[] \| readonly `string`[] | Array of allowed string values for enum-type arguments. Required when `type: 'enum'`. The argument value must be one of these choices, otherwise an `ArgResolveError` with type 'type' will be thrown. Supports both mutable arrays and readonly arrays for type safety. **Example** Enum choices: `{ logLevel: { type: 'enum', choices: ['debug', 'info', 'warn', 'error'] as const, default: 'info', description: 'Logging verbosity level' }, format: { type: 'enum', choices: ['json', 'yaml', 'toml'], description: 'Output format' } }` |
|
|
48
|
+
| <a id="property-conflicts"></a> `conflicts?` | `string` \| `string`[] | Names of other options that conflict with this option. When this option is used together with any of the conflicting options, an `ArgResolveError` with type 'conflict' will be thrown. Conflicts only need to be defined on one side - if option A defines a conflict with option B, the conflict is automatically detected when both are used, regardless of whether B also defines a conflict with A. Supports both single option name or array of option names. Option names must match the property keys in the schema object exactly (no automatic conversion between camelCase and kebab-case). **Examples** Single conflict (bidirectional definition): `{ summer: { type: 'boolean', conflicts: 'autumn' // Cannot use --summer with --autumn }, autumn: { type: 'boolean', conflicts: 'summer' // Can define on both sides for clarity } }` Single conflict (one-way definition): `{ summer: { type: 'boolean', conflicts: 'autumn' // Only defined on summer side }, autumn: { type: 'boolean' // No conflicts defined, but still cannot use with --summer } } // Usage: --summer --autumn will throw error // Error: "Optional argument '--summer' conflicts with '--autumn'"` Multiple conflicts: `{ port: { type: 'number', conflicts: ['socket', 'pipe'], // Cannot use with --socket or --pipe description: 'TCP port number' }, socket: { type: 'string', conflicts: ['port', 'pipe'], // Cannot use with --port or --pipe description: 'Unix socket path' }, pipe: { type: 'string', conflicts: ['port', 'socket'], // Cannot use with --port or --socket description: 'Named pipe path' } } // These three options are mutually exclusive` With kebab-case conversion: `{ summerSeason: { type: 'boolean', toKebab: true, // Accessible as --summer-season conflicts: 'autumnSeason' // Must use property key, not CLI name }, autumnSeason: { type: 'boolean', toKebab: true // Accessible as --autumn-season } } // Error: "Optional argument '--summer-season' conflicts with '--autumn-season'"` |
|
|
49
|
+
| <a id="property-default"></a> `default?` | `string` \| `number` \| `boolean` | Default value used when the argument is not provided. The type must match the argument's `type` property: - `string` type: string default - `boolean` type: boolean default - `number` type: number default - `enum` type: must be one of the `choices` values - `positional`/`custom` type: any appropriate default **Example** Default values by type: `{ host: { type: 'string', default: 'localhost' // string default }, verbose: { type: 'boolean', default: false // boolean default }, port: { type: 'number', default: 8080 // number default }, level: { type: 'enum', choices: ['low', 'high'], default: 'low' // must be in choices } }` |
|
|
50
|
+
| <a id="property-description"></a> `description?` | `string` | Human-readable description of the argument's purpose. Used for help text generation and documentation. Should be concise but descriptive enough to understand the argument's role. **Example** Descriptive help text: `{ config: { type: 'string', description: 'Path to configuration file' }, timeout: { type: 'number', description: 'Request timeout in milliseconds' } }` |
|
|
51
|
+
| <a id="property-metavar"></a> `metavar?` | `string` | Display name hint for help text generation. Provides a meaningful type hint for the argument value in help output. Particularly useful for `type: 'custom'` arguments where the type name would otherwise be unhelpful. **Example** Metavar usage: `{ port: { type: 'custom', parse: (v: string) => parseInt(v, 10), metavar: 'integer', description: 'Port number (1-65535)' } } // Help output: --port <integer> Port number (1-65535)` |
|
|
52
|
+
| <a id="property-multiple"></a> `multiple?` | `true` | Allows the argument to accept multiple values. When `true`, the resolved value becomes an array. For options: can be specified multiple times (--tag foo --tag bar) For positional: collects remaining positional arguments Note: Only `true` is allowed (not `false`) to make intent explicit. **Example** Multiple values: `{ tags: { type: 'string', multiple: true, // --tags foo --tags bar → ['foo', 'bar'] description: 'Tags to apply' }, files: { type: 'positional', multiple: true // Collects all remaining positional args } }` |
|
|
53
|
+
| <a id="property-negatable"></a> `negatable?` | `boolean` | Enables negation for boolean arguments using `--no-` prefix. When `true`, allows users to explicitly set the boolean to `false` using `--no-option-name`. When `false` or omitted, only positive form is available. Only applicable to `type: 'boolean'` arguments. **Example** Negatable boolean: `{ color: { type: 'boolean', negatable: true, default: true, description: 'Enable colorized output' } // Usage: --color (true), --no-color (false) }` |
|
|
54
|
+
| <a id="property-parse"></a> `parse?` | (`value`) => `any` | Custom parsing function for `type: 'custom'` arguments. Required when `type: 'custom'`. Receives the raw string value and must return the parsed result. Should throw an Error (or subclass) if parsing fails. The function's return type becomes the resolved argument type. **Throws** Error or subclass when value is invalid **Example** Custom parsing functions: `{ config: { type: 'custom', parse: (value: string) => { try { return JSON.parse(value) // Parse JSON config } catch { throw new Error('Invalid JSON configuration') } }, description: 'JSON configuration object' }, date: { type: 'custom', parse: (value: string) => { const date = new Date(value) if (isNaN(date.getTime())) { throw new Error('Invalid date format') } return date } } }` |
|
|
55
|
+
| <a id="property-required"></a> `required?` | `boolean` | Marks the argument as required. When `true`, the argument must be provided by the user. If missing, an `ArgResolveError` with type 'required' will be thrown. Note: Only `true` is allowed (not `false`) to make intent explicit. **Example** Required arguments: `{ input: { type: 'string', required: true, // Must be provided: --input file.txt description: 'Input file path' }, source: { type: 'positional', required: true // First positional argument must exist } }` |
|
|
56
|
+
| <a id="property-short"></a> `short?` | `string` | Single character alias for the long option name. As example, allows users to use `-x` instead of `--extended-option`. Only valid for non-positional argument types. **Example** Short alias usage: `{ verbose: { type: 'boolean', short: 'v' // Enables both --verbose and -v }, port: { type: 'number', short: 'p' // Enables both --port 3000 and -p 3000 } }` |
|
|
57
|
+
| <a id="property-tokebab"></a> `toKebab?` | `true` | Converts the argument name from camelCase to kebab-case for CLI usage. When `true`, a property like `maxCount` becomes available as `--max-count`. This allows [CAC](https://github.com/cacjs/cac) user-friendly property names while maintaining CLI conventions. Can be overridden globally with `resolveArgs({ toKebab: true })`. Note: Only `true` is allowed (not `false`) to make intent explicit. **Example** Kebab-case conversion: `{ maxRetries: { type: 'number', toKebab: true, // Accessible as --max-retries description: 'Maximum retry attempts' }, enableLogging: { type: 'boolean', toKebab: true // Accessible as --enable-logging } }` |
|
|
58
|
+
| <a id="property-type"></a> `type` | `"string"` \| `"number"` \| `"boolean"` \| `"positional"` \| `"enum"` \| `"custom"` | Type of the argument value. - `'string'`: Text value (default if not specified) - `'boolean'`: `true`/`false` flag (can be negatable with `--no-` prefix) - `'number'`: Numeric value (parsed as integer or float) - `'enum'`: One of predefined string values (requires `choices` property) - `'positional'`: Non-option argument by position - `'custom'`: Custom parsing with user-defined `parse` function **Example** Different argument types: `{ name: { type: 'string' }, // --name value verbose: { type: 'boolean' }, // --verbose or --no-verbose port: { type: 'number' }, // --port 3000 level: { type: 'enum', choices: ['debug', 'info'] }, file: { type: 'positional' }, // first positional arg config: { type: 'custom', parse: JSON.parse } }` |
|
|
@@ -8,9 +8,9 @@ Argument token.
|
|
|
8
8
|
|
|
9
9
|
| Property | Type | Description |
|
|
10
10
|
| ------ | ------ | ------ |
|
|
11
|
-
| <a id="index"></a> `index` | `number` | Argument token index, e.g `--foo bar` => `--foo` index is 0, `bar` index is 1. |
|
|
12
|
-
| <a id="inlinevalue"></a> `inlineValue?` | `boolean` | Inline value, e.g. `--foo=bar` => `true`, `-x=bar` => `true`. |
|
|
13
|
-
| <a id="kind"></a> `kind` | `ArgTokenKind` | Argument token kind. |
|
|
14
|
-
| <a id="name"></a> `name?` | `string` | Option name, e.g. `--foo` => `foo`, `-x` => `x`. |
|
|
15
|
-
| <a id="rawname"></a> `rawName?` | `string` | Raw option name, e.g. `--foo` => `--foo`, `-x` => `-x`. |
|
|
16
|
-
| <a id="value"></a> `value?` | `string` | Option value, e.g. `--foo=bar` => `bar`, `-x=bar` => `bar`. If the `allowCompatible` option is `true`, short option value will be same as Node.js `parseArgs` behavior. |
|
|
11
|
+
| <a id="property-index"></a> `index` | `number` | Argument token index, e.g `--foo bar` => `--foo` index is 0, `bar` index is 1. |
|
|
12
|
+
| <a id="property-inlinevalue"></a> `inlineValue?` | `boolean` | Inline value, e.g. `--foo=bar` => `true`, `-x=bar` => `true`. |
|
|
13
|
+
| <a id="property-kind"></a> `kind` | `ArgTokenKind` | Argument token kind. |
|
|
14
|
+
| <a id="property-name"></a> `name?` | `string` | Option name, e.g. `--foo` => `foo`, `-x` => `x`. |
|
|
15
|
+
| <a id="property-rawname"></a> `rawName?` | `string` | Raw option name, e.g. `--foo` => `--foo`, `-x` => `-x`. |
|
|
16
|
+
| <a id="property-value"></a> `value?` | `string` | Option value, e.g. `--foo=bar` => `bar`, `-x=bar` => `bar`. If the `allowCompatible` option is `true`, short option value will be same as Node.js `parseArgs` behavior. |
|
|
@@ -14,21 +14,21 @@ CLI options of [`cli`](../functions/cli.md) function.
|
|
|
14
14
|
|
|
15
15
|
| Property | Type | Description |
|
|
16
16
|
| ------ | ------ | ------ |
|
|
17
|
-
| <a id="cwd"></a> `cwd?` | `string` | Current working directory. |
|
|
18
|
-
| <a id="description"></a> `description?` | `string` | Command program description. |
|
|
19
|
-
| <a id="fallbacktoentry"></a> `fallbackToEntry?` | `boolean` | Whether to fallback to entry command when the sub-command is not found. **Default** `false` **Since** v0.27.0 |
|
|
20
|
-
| <a id="leftmargin"></a> `leftMargin?` | `number` | Left margin of the command output. |
|
|
21
|
-
| <a id="middlemargin"></a> `middleMargin?` | `number` | Middle margin of the command output. |
|
|
22
|
-
| <a id="name"></a> `name?` | `string` | Command program name. |
|
|
23
|
-
| <a id="onaftercommand"></a> `onAfterCommand?` | (`ctx`, `result`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> | Hook that runs after successful command execution **Since** v0.27.0 |
|
|
24
|
-
| <a id="onbeforecommand"></a> `onBeforeCommand?` | (`ctx`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> | Hook that runs before any command execution **Since** v0.27.0 |
|
|
25
|
-
| <a id="onerrorcommand"></a> `onErrorCommand?` | (`ctx`, `error`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> | Hook that runs when a command throws an error **Since** v0.27.0 |
|
|
26
|
-
| <a id="plugins"></a> `plugins?` | [`Plugin`](../type-aliases/Plugin.md)[] | User plugins. **Since** v0.27.0 |
|
|
27
|
-
| <a id="renderheader"></a> `renderHeader?` | (`ctx`) => `Promise`\<`string`\> \| `null` | Render function the header section in the command usage. |
|
|
28
|
-
| <a id="renderusage"></a> `renderUsage?` | (`ctx`) => `Promise`\<`string`\> \| `null` | Render function the command usage. |
|
|
29
|
-
| <a id="rendervalidationerrors"></a> `renderValidationErrors?` | (`ctx`, `error`) => `Promise`\<`string`\> \| `null` | Render function the validation errors. |
|
|
30
|
-
| <a id="subcommands"></a> `subCommands?` | \| `Record`\<`string`, [`SubCommandable`](SubCommandable.md)\> \| `Map`\<`string`, [`SubCommandable`](SubCommandable.md)\> | Sub commands. |
|
|
31
|
-
| <a id="usageoptiontype"></a> `usageOptionType?` | `boolean` | Whether to display the usage optional argument type. |
|
|
32
|
-
| <a id="usageoptionvalue"></a> `usageOptionValue?` | `boolean` | Whether to display the optional argument value. |
|
|
33
|
-
| <a id="usagesilent"></a> `usageSilent?` | `boolean` | Whether to display the command usage. |
|
|
34
|
-
| <a id="version"></a> `version?` | `string` | Command program version. |
|
|
17
|
+
| <a id="property-cwd"></a> `cwd?` | `string` | Current working directory. |
|
|
18
|
+
| <a id="property-description"></a> `description?` | `string` | Command program description. |
|
|
19
|
+
| <a id="property-fallbacktoentry"></a> `fallbackToEntry?` | `boolean` | Whether to fallback to entry command when the sub-command is not found. **Default** `false` **Since** v0.27.0 |
|
|
20
|
+
| <a id="property-leftmargin"></a> `leftMargin?` | `number` | Left margin of the command output. |
|
|
21
|
+
| <a id="property-middlemargin"></a> `middleMargin?` | `number` | Middle margin of the command output. |
|
|
22
|
+
| <a id="property-name"></a> `name?` | `string` | Command program name. |
|
|
23
|
+
| <a id="property-onaftercommand"></a> `onAfterCommand?` | (`ctx`, `result`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> | Hook that runs after successful command execution **Since** v0.27.0 |
|
|
24
|
+
| <a id="property-onbeforecommand"></a> `onBeforeCommand?` | (`ctx`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> | Hook that runs before any command execution **Since** v0.27.0 |
|
|
25
|
+
| <a id="property-onerrorcommand"></a> `onErrorCommand?` | (`ctx`, `error`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> | Hook that runs when a command throws an error **Since** v0.27.0 |
|
|
26
|
+
| <a id="property-plugins"></a> `plugins?` | [`Plugin`](../type-aliases/Plugin.md)[] | User plugins. **Since** v0.27.0 |
|
|
27
|
+
| <a id="property-renderheader"></a> `renderHeader?` | (`ctx`) => `Promise`\<`string`\> \| `null` | Render function the header section in the command usage. |
|
|
28
|
+
| <a id="property-renderusage"></a> `renderUsage?` | (`ctx`) => `Promise`\<`string`\> \| `null` | Render function the command usage. |
|
|
29
|
+
| <a id="property-rendervalidationerrors"></a> `renderValidationErrors?` | (`ctx`, `error`) => `Promise`\<`string`\> \| `null` | Render function the validation errors. |
|
|
30
|
+
| <a id="property-subcommands"></a> `subCommands?` | \| `Record`\<`string`, [`SubCommandable`](SubCommandable.md)\> \| `Map`\<`string`, [`SubCommandable`](SubCommandable.md)\> | Sub commands. |
|
|
31
|
+
| <a id="property-usageoptiontype"></a> `usageOptionType?` | `boolean` | Whether to display the usage optional argument type. |
|
|
32
|
+
| <a id="property-usageoptionvalue"></a> `usageOptionValue?` | `boolean` | Whether to display the optional argument value. |
|
|
33
|
+
| <a id="property-usagesilent"></a> `usageSilent?` | `boolean` | Whether to display the command usage. |
|
|
34
|
+
| <a id="property-version"></a> `version?` | `string` | Command program version. |
|
|
@@ -14,13 +14,13 @@ Command interface.
|
|
|
14
14
|
|
|
15
15
|
| Property | Type | Description |
|
|
16
16
|
| ------ | ------ | ------ |
|
|
17
|
-
| <a id="args"></a> `args?` | `ExtractArgs`\<`G`\> | Command arguments. Each argument can include a description property to describe the argument in usage. |
|
|
18
|
-
| <a id="description"></a> `description?` | `string` | Command description. It's used to describe the command in usage and it's recommended to specify. |
|
|
19
|
-
| <a id="entry"></a> `entry?` | `boolean` | Whether this command is an entry command. **Default** `undefined` **Since** v0.27.0 |
|
|
20
|
-
| <a id="examples"></a> `examples?` | \| `string` \| [`CommandExamplesFetcher`](../type-aliases/CommandExamplesFetcher.md)\<`G`\> | Command examples. examples of how to use the command. |
|
|
21
|
-
| <a id="internal"></a> `internal?` | `boolean` | Whether this is an internal command. Internal commands are not shown in help usage. **Default** `false` **Since** v0.27.0 |
|
|
22
|
-
| <a id="name"></a> `name?` | `string` | Command name. It's used to find command line arguments to execute from sub commands, and it's recommended to specify. |
|
|
23
|
-
| <a id="rendering"></a> `rendering?` | [`RenderingOptions`](RenderingOptions.md)\<`G`\> | Rendering control options **Since** v0.27.0 |
|
|
24
|
-
| <a id="run"></a> `run?` | [`CommandRunner`](../type-aliases/CommandRunner.md)\<`G`\> | Command runner. it's the command to be executed |
|
|
25
|
-
| <a id="subcommands"></a> `subCommands?` | \| `Record`\<`string`, [`SubCommandable`](SubCommandable.md)\> \| `Map`\<`string`, [`SubCommandable`](SubCommandable.md)\> | Nested sub-commands for this command. Allows building command trees like `git remote add`. Each key is the sub-command name, and the value is a command or lazy command. **Since** v0.28.0 |
|
|
26
|
-
| <a id="tokebab"></a> `toKebab?` | `boolean` | Whether to convert the camel-case style argument name to kebab-case. If you will set to `true`, All [`Command.args`](#args) names will be converted to kebab-case. |
|
|
17
|
+
| <a id="property-args"></a> `args?` | `ExtractArgs`\<`G`\> | Command arguments. Each argument can include a description property to describe the argument in usage. |
|
|
18
|
+
| <a id="property-description"></a> `description?` | `string` | Command description. It's used to describe the command in usage and it's recommended to specify. |
|
|
19
|
+
| <a id="property-entry"></a> `entry?` | `boolean` | Whether this command is an entry command. **Default** `undefined` **Since** v0.27.0 |
|
|
20
|
+
| <a id="property-examples"></a> `examples?` | \| `string` \| [`CommandExamplesFetcher`](../type-aliases/CommandExamplesFetcher.md)\<`G`\> | Command examples. examples of how to use the command. |
|
|
21
|
+
| <a id="property-internal"></a> `internal?` | `boolean` | Whether this is an internal command. Internal commands are not shown in help usage. **Default** `false` **Since** v0.27.0 |
|
|
22
|
+
| <a id="property-name"></a> `name?` | `string` | Command name. It's used to find command line arguments to execute from sub commands, and it's recommended to specify. |
|
|
23
|
+
| <a id="property-rendering"></a> `rendering?` | [`RenderingOptions`](RenderingOptions.md)\<`G`\> | Rendering control options **Since** v0.27.0 |
|
|
24
|
+
| <a id="property-run"></a> `run?` | [`CommandRunner`](../type-aliases/CommandRunner.md)\<`G`\> | Command runner. it's the command to be executed |
|
|
25
|
+
| <a id="property-subcommands"></a> `subCommands?` | \| `Record`\<`string`, [`SubCommandable`](SubCommandable.md)\> \| `Map`\<`string`, [`SubCommandable`](SubCommandable.md)\> | Nested sub-commands for this command. Allows building command trees like `git remote add`. Each key is the sub-command name, and the value is a command or lazy command. **Since** v0.28.0 |
|
|
26
|
+
| <a id="property-tokebab"></a> `toKebab?` | `boolean` | Whether to convert the camel-case style argument name to kebab-case. If you will set to `true`, All [`Command.args`](#property-args) names will be converted to kebab-case. |
|
|
@@ -16,20 +16,20 @@ Command context is the context of the command execution.
|
|
|
16
16
|
|
|
17
17
|
| Property | Type | Description |
|
|
18
18
|
| ------ | ------ | ------ |
|
|
19
|
-
| <a id="_"></a> `_` | `string`[] | Original command line arguments. This argument is passed from `cli` function. |
|
|
20
|
-
| <a id="args"></a> `args` | `ExtractArgs`\<`G`\> | Command arguments, that is the arguments of the command that is executed. The command arguments is same [`Command.args`](Command.md#args). |
|
|
21
|
-
| <a id="callmode"></a> `callMode` | [`CommandCallMode`](../type-aliases/CommandCallMode.md) | Command call mode. The command call mode is `entry` when the command is executed as an entry command, and `subCommand` when the command is executed as a sub-command. |
|
|
22
|
-
| <a id="commandpath"></a> `commandPath` | `string`[] | The path of nested sub-commands that were resolved to reach the current command. For example, if the user runs `git remote add`, `commandPath` would be `['remote', 'add']`. For the entry command, this is an empty array. **Since** v0.28.0 |
|
|
23
|
-
| <a id="description"></a> `description` | `string` \| `undefined` | Command description, that is the description of the command that is executed. The command description is same [`CommandEnvironment.description`](CommandEnvironment.md#description). |
|
|
24
|
-
| <a id="env"></a> `env` | `Readonly`\<[`CommandEnvironment`](CommandEnvironment.md)\<`G`\>\> | Command environment, that is the environment of the command that is executed. The command environment is same [`CommandEnvironment`](CommandEnvironment.md). |
|
|
25
|
-
| <a id="explicit"></a> `explicit` | `ExtractArgExplicitlyProvided`\<`G`\> | Whether arguments were explicitly provided by the user. - `true`: The argument was explicitly provided via command line - `false`: The argument was not explicitly provided. This means either: - The value comes from a default value defined in the argument schema - The value is `undefined` (no explicit input and no default value) |
|
|
26
|
-
| <a id="extensions"></a> `extensions` | keyof `ExtractExtensions`\<`G`\> *extends* `never` ? `any` : `ExtractExtensions`\<`G`\> | Command context extensions. **Since** v0.27.0 |
|
|
27
|
-
| <a id="log"></a> `log` | (`message?`, ...`optionalParams`) => `void` | Output a message. If [`CommandEnvironment.usageSilent`](CommandEnvironment.md#usagesilent) is true, the message is not output. |
|
|
28
|
-
| <a id="name"></a> `name` | `string` \| `undefined` | Command name, that is the command that is executed. The command name is same [`CommandEnvironment.name`](CommandEnvironment.md#name). |
|
|
29
|
-
| <a id="omitted"></a> `omitted` | `boolean` | Whether the currently executing command has been executed with the sub-command name omitted. |
|
|
30
|
-
| <a id="positionals"></a> `positionals` | `string`[] | Command positionals arguments, that is the positionals of the command that is executed. Resolve positionals with `resolveArgs` from command arguments. |
|
|
31
|
-
| <a id="rest"></a> `rest` | `string`[] | Command rest arguments, that is the remaining argument not resolved by the optional command option delimiter `--`. |
|
|
32
|
-
| <a id="tokebab"></a> `toKebab?` | `boolean` | Whether to convert the camel-case style argument name to kebab-case. This context value is set from [`Command.toKebab`](Command.md#tokebab) option. |
|
|
33
|
-
| <a id="tokens"></a> `tokens` | [`ArgToken`](ArgToken.md)[] | Argument tokens, that is parsed by `parseArgs` function. |
|
|
34
|
-
| <a id="validationerror"></a> `validationError?` | `AggregateError` | Validation error from argument parsing. This will be set if argument validation fails during CLI execution. |
|
|
35
|
-
| <a id="values"></a> `values` | [`ArgValues`](../type-aliases/ArgValues.md)\<`ExtractArgs`\<`G`\>\> | Command values, that is the values of the command that is executed. Resolve values with `resolveArgs` from command arguments and [`Command.args`](Command.md#args). |
|
|
19
|
+
| <a id="property-_"></a> `_` | `string`[] | Original command line arguments. This argument is passed from `cli` function. |
|
|
20
|
+
| <a id="property-args"></a> `args` | `ExtractArgs`\<`G`\> | Command arguments, that is the arguments of the command that is executed. The command arguments is same [`Command.args`](Command.md#property-args). |
|
|
21
|
+
| <a id="property-callmode"></a> `callMode` | [`CommandCallMode`](../type-aliases/CommandCallMode.md) | Command call mode. The command call mode is `entry` when the command is executed as an entry command, and `subCommand` when the command is executed as a sub-command. |
|
|
22
|
+
| <a id="property-commandpath"></a> `commandPath` | `string`[] | The path of nested sub-commands that were resolved to reach the current command. For example, if the user runs `git remote add`, `commandPath` would be `['remote', 'add']`. For the entry command, this is an empty array. **Since** v0.28.0 |
|
|
23
|
+
| <a id="property-description"></a> `description` | `string` \| `undefined` | Command description, that is the description of the command that is executed. The command description is same [`CommandEnvironment.description`](CommandEnvironment.md#property-description). |
|
|
24
|
+
| <a id="property-env"></a> `env` | `Readonly`\<[`CommandEnvironment`](CommandEnvironment.md)\<`G`\>\> | Command environment, that is the environment of the command that is executed. The command environment is same [`CommandEnvironment`](CommandEnvironment.md). |
|
|
25
|
+
| <a id="property-explicit"></a> `explicit` | `ExtractArgExplicitlyProvided`\<`G`\> | Whether arguments were explicitly provided by the user. - `true`: The argument was explicitly provided via command line - `false`: The argument was not explicitly provided. This means either: - The value comes from a default value defined in the argument schema - The value is `undefined` (no explicit input and no default value) |
|
|
26
|
+
| <a id="property-extensions"></a> `extensions` | keyof `ExtractExtensions`\<`G`\> *extends* `never` ? `any` : `ExtractExtensions`\<`G`\> | Command context extensions. **Since** v0.27.0 |
|
|
27
|
+
| <a id="property-log"></a> `log` | (`message?`, ...`optionalParams`) => `void` | Output a message. If [`CommandEnvironment.usageSilent`](CommandEnvironment.md#property-usagesilent) is true, the message is not output. |
|
|
28
|
+
| <a id="property-name"></a> `name` | `string` \| `undefined` | Command name, that is the command that is executed. The command name is same [`CommandEnvironment.name`](CommandEnvironment.md#property-name). |
|
|
29
|
+
| <a id="property-omitted"></a> `omitted` | `boolean` | Whether the currently executing command has been executed with the sub-command name omitted. |
|
|
30
|
+
| <a id="property-positionals"></a> `positionals` | `string`[] | Command positionals arguments, that is the positionals of the command that is executed. Resolve positionals with `resolveArgs` from command arguments. |
|
|
31
|
+
| <a id="property-rest"></a> `rest` | `string`[] | Command rest arguments, that is the remaining argument not resolved by the optional command option delimiter `--`. |
|
|
32
|
+
| <a id="property-tokebab"></a> `toKebab?` | `boolean` | Whether to convert the camel-case style argument name to kebab-case. This context value is set from [`Command.toKebab`](Command.md#property-tokebab) option. |
|
|
33
|
+
| <a id="property-tokens"></a> `tokens` | [`ArgToken`](ArgToken.md)[] | Argument tokens, that is parsed by `parseArgs` function. |
|
|
34
|
+
| <a id="property-validationerror"></a> `validationError?` | `AggregateError` | Validation error from argument parsing. This will be set if argument validation fails during CLI execution. |
|
|
35
|
+
| <a id="property-values"></a> `values` | [`ArgValues`](../type-aliases/ArgValues.md)\<`ExtractArgs`\<`G`\>\> | Command values, that is the values of the command that is executed. Resolve values with `resolveArgs` from command arguments and [`Command.args`](Command.md#property-args). |
|
|
@@ -12,12 +12,12 @@ v0.27.0
|
|
|
12
12
|
|
|
13
13
|
| Type Parameter | Default type | Description |
|
|
14
14
|
| ------ | ------ | ------ |
|
|
15
|
-
| `E` *extends* [`GunshiParams`](GunshiParams.md)\[`"extensions"`\] | [`DefaultGunshiParams`](../type-aliases/DefaultGunshiParams.md)\[`"extensions"`\] | A type extending [`GunshiParams.extensions`](GunshiParams.md#extensions) to specify the shape of the extension. |
|
|
15
|
+
| `E` *extends* [`GunshiParams`](GunshiParams.md)\[`"extensions"`\] | [`DefaultGunshiParams`](../type-aliases/DefaultGunshiParams.md)\[`"extensions"`\] | A type extending [`GunshiParams.extensions`](GunshiParams.md#property-extensions) to specify the shape of the extension. |
|
|
16
16
|
|
|
17
17
|
## Properties
|
|
18
18
|
|
|
19
19
|
| Property | Modifier | Type | Description |
|
|
20
20
|
| ------ | ------ | ------ | ------ |
|
|
21
|
-
| <a id="factory"></a> `factory` | `readonly` | (`ctx`, `cmd`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`E`\> | Plugin extension factory |
|
|
22
|
-
| <a id="key"></a> `key` | `readonly` | `symbol` | Plugin identifier |
|
|
23
|
-
| <a id="onfactory"></a> `onFactory?` | `readonly` | (`ctx`, `cmd`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> | Plugin extension factory after hook |
|
|
21
|
+
| <a id="property-factory"></a> `factory` | `readonly` | (`ctx`, `cmd`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`E`\> | Plugin extension factory |
|
|
22
|
+
| <a id="property-key"></a> `key` | `readonly` | `symbol` | Plugin identifier |
|
|
23
|
+
| <a id="property-onfactory"></a> `onFactory?` | `readonly` | (`ctx`, `cmd`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> | Plugin extension factory after hook |
|
|
@@ -14,19 +14,19 @@ Command environment.
|
|
|
14
14
|
|
|
15
15
|
| Property | Type | Description |
|
|
16
16
|
| ------ | ------ | ------ |
|
|
17
|
-
| <a id="cwd"></a> `cwd` | `string` \| `undefined` | Current working directory. **See** [`CliOptions.cwd`](CliOptions.md#cwd) |
|
|
18
|
-
| <a id="description"></a> `description` | `string` \| `undefined` | Command description. **See** [`CliOptions.description`](CliOptions.md#description) |
|
|
19
|
-
| <a id="leftmargin"></a> `leftMargin` | `number` | Left margin of the command output. **Default** `2` **See** [`CliOptions.leftMargin`](CliOptions.md#leftmargin) |
|
|
20
|
-
| <a id="middlemargin"></a> `middleMargin` | `number` | Middle margin of the command output. **Default** `10` **See** [`CliOptions.middleMargin`](CliOptions.md#middlemargin) |
|
|
21
|
-
| <a id="name"></a> `name` | `string` \| `undefined` | Command name. **See** [`CliOptions.name`](CliOptions.md#name) |
|
|
22
|
-
| <a id="onaftercommand"></a> `onAfterCommand` | \| (`ctx`, `result`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> \| `undefined` | Hook that runs after successful command execution **See** [`CliOptions.onAfterCommand`](CliOptions.md#onaftercommand) **Since** v0.27.0 |
|
|
23
|
-
| <a id="onbeforecommand"></a> `onBeforeCommand` | \| (`ctx`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> \| `undefined` | Hook that runs before any command execution **See** [`CliOptions.onBeforeCommand`](CliOptions.md#onbeforecommand) **Since** v0.27.0 |
|
|
24
|
-
| <a id="onerrorcommand"></a> `onErrorCommand` | \| (`ctx`, `error`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> \| `undefined` | Hook that runs when a command throws an error **See** [`CliOptions.onErrorCommand`](CliOptions.md#onerrorcommand) **Since** v0.27.0 |
|
|
25
|
-
| <a id="renderheader"></a> `renderHeader` | (`ctx`) => `Promise`\<`string`\> \| `null` \| `undefined` | Render function the header section in the command usage. |
|
|
26
|
-
| <a id="renderusage"></a> `renderUsage` | (`ctx`) => `Promise`\<`string`\> \| `null` \| `undefined` | Render function the command usage. |
|
|
27
|
-
| <a id="rendervalidationerrors"></a> `renderValidationErrors` | (`ctx`, `error`) => `Promise`\<`string`\> \| `null` \| `undefined` | Render function the validation errors. |
|
|
28
|
-
| <a id="subcommands"></a> `subCommands` | \| `Map`\<`string`, \| [`Command`](Command.md)\<`any`\> \| [`LazyCommand`](../type-aliases/LazyCommand.md)\<`any`, \{ \}\>\> \| `undefined` | Sub commands. **See** [`CliOptions.subCommands`](CliOptions.md#subcommands) |
|
|
29
|
-
| <a id="usageoptiontype"></a> `usageOptionType` | `boolean` | Whether to display the usage option type. **Default** `false` **See** [`CliOptions.usageOptionType`](CliOptions.md#usageoptiontype) |
|
|
30
|
-
| <a id="usageoptionvalue"></a> `usageOptionValue` | `boolean` | Whether to display the option value. **Default** `true` **See** [`CliOptions.usageOptionValue`](CliOptions.md#usageoptionvalue) |
|
|
31
|
-
| <a id="usagesilent"></a> `usageSilent` | `boolean` | Whether to display the command usage. **Default** `false` **See** [`CliOptions.usageSilent`](CliOptions.md#usagesilent) |
|
|
32
|
-
| <a id="version"></a> `version` | `string` \| `undefined` | Command version. **See** [`CliOptions.version`](CliOptions.md#version) |
|
|
17
|
+
| <a id="property-cwd"></a> `cwd` | `string` \| `undefined` | Current working directory. **See** [`CliOptions.cwd`](CliOptions.md#property-cwd) |
|
|
18
|
+
| <a id="property-description"></a> `description` | `string` \| `undefined` | Command description. **See** [`CliOptions.description`](CliOptions.md#property-description) |
|
|
19
|
+
| <a id="property-leftmargin"></a> `leftMargin` | `number` | Left margin of the command output. **Default** `2` **See** [`CliOptions.leftMargin`](CliOptions.md#property-leftmargin) |
|
|
20
|
+
| <a id="property-middlemargin"></a> `middleMargin` | `number` | Middle margin of the command output. **Default** `10` **See** [`CliOptions.middleMargin`](CliOptions.md#property-middlemargin) |
|
|
21
|
+
| <a id="property-name"></a> `name` | `string` \| `undefined` | Command name. **See** [`CliOptions.name`](CliOptions.md#property-name) |
|
|
22
|
+
| <a id="property-onaftercommand"></a> `onAfterCommand` | \| (`ctx`, `result`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> \| `undefined` | Hook that runs after successful command execution **See** [`CliOptions.onAfterCommand`](CliOptions.md#property-onaftercommand) **Since** v0.27.0 |
|
|
23
|
+
| <a id="property-onbeforecommand"></a> `onBeforeCommand` | \| (`ctx`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> \| `undefined` | Hook that runs before any command execution **See** [`CliOptions.onBeforeCommand`](CliOptions.md#property-onbeforecommand) **Since** v0.27.0 |
|
|
24
|
+
| <a id="property-onerrorcommand"></a> `onErrorCommand` | \| (`ctx`, `error`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> \| `undefined` | Hook that runs when a command throws an error **See** [`CliOptions.onErrorCommand`](CliOptions.md#property-onerrorcommand) **Since** v0.27.0 |
|
|
25
|
+
| <a id="property-renderheader"></a> `renderHeader` | (`ctx`) => `Promise`\<`string`\> \| `null` \| `undefined` | Render function the header section in the command usage. |
|
|
26
|
+
| <a id="property-renderusage"></a> `renderUsage` | (`ctx`) => `Promise`\<`string`\> \| `null` \| `undefined` | Render function the command usage. |
|
|
27
|
+
| <a id="property-rendervalidationerrors"></a> `renderValidationErrors` | (`ctx`, `error`) => `Promise`\<`string`\> \| `null` \| `undefined` | Render function the validation errors. |
|
|
28
|
+
| <a id="property-subcommands"></a> `subCommands` | \| `Map`\<`string`, \| [`Command`](Command.md)\<`any`\> \| [`LazyCommand`](../type-aliases/LazyCommand.md)\<`any`, \{ \}\>\> \| `undefined` | Sub commands. **See** [`CliOptions.subCommands`](CliOptions.md#property-subcommands) |
|
|
29
|
+
| <a id="property-usageoptiontype"></a> `usageOptionType` | `boolean` | Whether to display the usage option type. **Default** `false` **See** [`CliOptions.usageOptionType`](CliOptions.md#property-usageoptiontype) |
|
|
30
|
+
| <a id="property-usageoptionvalue"></a> `usageOptionValue` | `boolean` | Whether to display the option value. **Default** `true` **See** [`CliOptions.usageOptionValue`](CliOptions.md#property-usageoptionvalue) |
|
|
31
|
+
| <a id="property-usagesilent"></a> `usageSilent` | `boolean` | Whether to display the command usage. **Default** `false` **See** [`CliOptions.usageSilent`](CliOptions.md#property-usagesilent) |
|
|
32
|
+
| <a id="property-version"></a> `version` | `string` \| `undefined` | Command version. **See** [`CliOptions.version`](CliOptions.md#property-version) |
|
|
@@ -20,5 +20,5 @@ v0.27.0
|
|
|
20
20
|
|
|
21
21
|
| Property | Type | Description |
|
|
22
22
|
| ------ | ------ | ------ |
|
|
23
|
-
| <a id="args"></a> `args` | `P` *extends* `object` ? `A` : [`Args`](Args.md) | Command argument definitions. |
|
|
24
|
-
| <a id="extensions"></a> `extensions` | `P` *extends* `object` ? `E` : `object` | Command context extensions. |
|
|
23
|
+
| <a id="property-args"></a> `args` | `P` *extends* `object` ? `A` : [`Args`](Args.md) | Command argument definitions. |
|
|
24
|
+
| <a id="property-extensions"></a> `extensions` | `P` *extends* `object` ? `E` : `object` | Command context extensions. |
|
|
@@ -188,5 +188,5 @@ True if the command exists, false otherwise
|
|
|
188
188
|
|
|
189
189
|
| Property | Modifier | Type | Description |
|
|
190
190
|
| ------ | ------ | ------ | ------ |
|
|
191
|
-
| <a id="globaloptions"></a> `globalOptions` | `readonly` | `Map`\<`string`, [`ArgSchema`](ArgSchema.md)\> | Get the global options |
|
|
192
|
-
| <a id="subcommands"></a> `subCommands` | `readonly` | `ReadonlyMap`\<`string`, \| [`Command`](Command.md)\<`G`\> \| [`LazyCommand`](../type-aliases/LazyCommand.md)\<`G`\>\> | Get the registered sub commands |
|
|
191
|
+
| <a id="property-globaloptions"></a> `globalOptions` | `readonly` | `Map`\<`string`, [`ArgSchema`](ArgSchema.md)\> | Get the global options |
|
|
192
|
+
| <a id="property-subcommands"></a> `subCommands` | `readonly` | `ReadonlyMap`\<`string`, \| [`Command`](Command.md)\<`G`\> \| [`LazyCommand`](../type-aliases/LazyCommand.md)\<`G`\>\> | Get the registered sub commands |
|
|
@@ -12,5 +12,5 @@ v0.27.0
|
|
|
12
12
|
|
|
13
13
|
| Property | Type | Description |
|
|
14
14
|
| ------ | ------ | ------ |
|
|
15
|
-
| <a id="id"></a> `id` | `string` | Dependency plugin id |
|
|
16
|
-
| <a id="optional"></a> `optional?` | `boolean` | Optional dependency flag. If `true`, the plugin will not throw an error if the dependency is not found |
|
|
15
|
+
| <a id="property-id"></a> `id` | `string` | Dependency plugin id |
|
|
16
|
+
| <a id="property-optional"></a> `optional?` | `boolean` | Optional dependency flag. If `true`, the plugin will not throw an error if the dependency is not found |
|
|
@@ -24,9 +24,9 @@ v0.27.0
|
|
|
24
24
|
|
|
25
25
|
| Property | Type | Description |
|
|
26
26
|
| ------ | ------ | ------ |
|
|
27
|
-
| <a id="dependencies"></a> `dependencies?` | `Deps` | Plugin dependencies |
|
|
28
|
-
| <a id="extension"></a> `extension?` | `PluginExt` | Plugin extension |
|
|
29
|
-
| <a id="id
|
|
30
|
-
| <a id="name"></a> `name?` | `string` | Plugin name |
|
|
31
|
-
| <a id="onextension"></a> `onExtension?` | [`OnPluginExtension`](../type-aliases/OnPluginExtension.md)\<`MergedExt`\> | Callback for when the plugin is extended with `extension` option. |
|
|
32
|
-
| <a id="setup"></a> `setup?` | [`PluginFunction`](../type-aliases/PluginFunction.md)\<`MergedExt`\> | Plugin setup function |
|
|
27
|
+
| <a id="property-dependencies"></a> `dependencies?` | `Deps` | Plugin dependencies |
|
|
28
|
+
| <a id="property-extension"></a> `extension?` | `PluginExt` | Plugin extension |
|
|
29
|
+
| <a id="property-id"></a> `id` | `Id` | Plugin unique identifier |
|
|
30
|
+
| <a id="property-name"></a> `name?` | `string` | Plugin name |
|
|
31
|
+
| <a id="property-onextension"></a> `onExtension?` | [`OnPluginExtension`](../type-aliases/OnPluginExtension.md)\<`MergedExt`\> | Callback for when the plugin is extended with `extension` option. |
|
|
32
|
+
| <a id="property-setup"></a> `setup?` | [`PluginFunction`](../type-aliases/PluginFunction.md)\<`MergedExt`\> | Plugin setup function |
|
|
@@ -38,7 +38,7 @@ This type is used to define a plugin at `plugin` function.
|
|
|
38
38
|
|
|
39
39
|
| Property | Type | Description | Overrides |
|
|
40
40
|
| ------ | ------ | ------ | ------ |
|
|
41
|
-
| <a id="dependencies"></a> `dependencies?` | (`string` \| [`PluginDependency`](PluginDependency.md))[] | Plugin dependencies | `Plugin.dependencies` |
|
|
42
|
-
| <a id="extension"></a> `extension` | [`CommandContextExtension`](CommandContextExtension.md)\<`E`\> | Plugin extension | `Plugin.extension` |
|
|
43
|
-
| <a id="id"></a> `id` | `string` | Plugin identifier | `Plugin.id` |
|
|
44
|
-
| <a id="name"></a> `name` | `string` | Plugin name | `Plugin.name` |
|
|
41
|
+
| <a id="property-dependencies"></a> `dependencies?` | (`string` \| [`PluginDependency`](PluginDependency.md))[] | Plugin dependencies | `Plugin.dependencies` |
|
|
42
|
+
| <a id="property-extension"></a> `extension` | [`CommandContextExtension`](CommandContextExtension.md)\<`E`\> | Plugin extension | `Plugin.extension` |
|
|
43
|
+
| <a id="property-id"></a> `id` | `string` | Plugin identifier | `Plugin.id` |
|
|
44
|
+
| <a id="property-name"></a> `name` | `string` | Plugin name | `Plugin.name` |
|
|
@@ -38,7 +38,7 @@ This type is used to define a plugin at `plugin` function without extension.
|
|
|
38
38
|
|
|
39
39
|
| Property | Type | Description | Overrides | Inherited from |
|
|
40
40
|
| ------ | ------ | ------ | ------ | ------ |
|
|
41
|
-
| <a id="dependencies"></a> `dependencies?` | (`string` \| [`PluginDependency`](PluginDependency.md))[] | Plugin dependencies | `Plugin.dependencies` | - |
|
|
42
|
-
| <a id="extension"></a> `extension?` | [`CommandContextExtension`](CommandContextExtension.md)\<`E`\> | - | - | `Plugin.extension` |
|
|
43
|
-
| <a id="id"></a> `id` | `string` | Plugin identifier | `Plugin.id` | - |
|
|
44
|
-
| <a id="name"></a> `name` | `string` | Plugin name | `Plugin.name` | - |
|
|
41
|
+
| <a id="property-dependencies"></a> `dependencies?` | (`string` \| [`PluginDependency`](PluginDependency.md))[] | Plugin dependencies | `Plugin.dependencies` | - |
|
|
42
|
+
| <a id="property-extension"></a> `extension?` | [`CommandContextExtension`](CommandContextExtension.md)\<`E`\> | - | - | `Plugin.extension` |
|
|
43
|
+
| <a id="property-id"></a> `id` | `string` | Plugin identifier | `Plugin.id` | - |
|
|
44
|
+
| <a id="property-name"></a> `name` | `string` | Plugin name | `Plugin.name` | - |
|
|
@@ -18,6 +18,6 @@ v0.27.0
|
|
|
18
18
|
|
|
19
19
|
| Property | Type | Description |
|
|
20
20
|
| ------ | ------ | ------ |
|
|
21
|
-
| <a id="header"></a> `header?` | (`ctx`) => `Promise`\<`string`\> \| `null` | Header rendering configuration - `null`: Disable rendering - `function`: Use custom renderer - `undefined` (when omitted): Use default renderer |
|
|
22
|
-
| <a id="usage"></a> `usage?` | (`ctx`) => `Promise`\<`string`\> \| `null` | Usage rendering configuration - `null`: Disable rendering - `function`: Use custom renderer - `undefined` (when omitted): Use default renderer |
|
|
23
|
-
| <a id="validationerrors"></a> `validationErrors?` | (`ctx`, `error`) => `Promise`\<`string`\> \| `null` | Validation errors rendering configuration - `null`: Disable rendering - `function`: Use custom renderer - `undefined` (when omitted): Use default renderer |
|
|
21
|
+
| <a id="property-header"></a> `header?` | (`ctx`) => `Promise`\<`string`\> \| `null` | Header rendering configuration - `null`: Disable rendering - `function`: Use custom renderer - `undefined` (when omitted): Use default renderer |
|
|
22
|
+
| <a id="property-usage"></a> `usage?` | (`ctx`) => `Promise`\<`string`\> \| `null` | Usage rendering configuration - `null`: Disable rendering - `function`: Use custom renderer - `undefined` (when omitted): Use default renderer |
|
|
23
|
+
| <a id="property-validationerrors"></a> `validationErrors?` | (`ctx`, `error`) => `Promise`\<`string`\> \| `null` | Validation errors rendering configuration - `null`: Disable rendering - `function`: Use custom renderer - `undefined` (when omitted): Use default renderer |
|
|
@@ -23,14 +23,14 @@ Index signature to allow additional properties
|
|
|
23
23
|
|
|
24
24
|
| Property | Type | Description |
|
|
25
25
|
| ------ | ------ | ------ |
|
|
26
|
-
| <a id="args"></a> `args?` | [`Args`](Args.md) \| `Record`\<`string`, `any`\> | see [Command.args](Command.md#args) |
|
|
27
|
-
| <a id="commandname"></a> `commandName?` | `string` | see LazyCommand.commandName |
|
|
28
|
-
| <a id="description"></a> `description?` | `string` | see [Command.description](Command.md#description) |
|
|
29
|
-
| <a id="entry"></a> `entry?` | `boolean` | see [Command.entry](Command.md#entry) |
|
|
30
|
-
| <a id="examples"></a> `examples?` | `string` \| (...`args`) => `any` | see [Command.examples](Command.md#examples) |
|
|
31
|
-
| <a id="internal"></a> `internal?` | `boolean` | see [Command.internal](Command.md#internal) |
|
|
32
|
-
| <a id="name"></a> `name?` | `string` | see [Command.name](Command.md#name) |
|
|
33
|
-
| <a id="rendering"></a> `rendering?` | `any` | see [Command.rendering](Command.md#rendering) |
|
|
34
|
-
| <a id="run"></a> `run?` | (...`args`) => `any` | see [Command.run](Command.md#run) |
|
|
35
|
-
| <a id="subcommands"></a> `subCommands?` | `Record`\<`string`, `any`\> \| `Map`\<`string`, `any`\> | Nested sub-commands for this command. **See** [Command.subCommands](Command.md#subcommands) **Since** v0.28.0 |
|
|
36
|
-
| <a id="tokebab"></a> `toKebab?` | `boolean` | see [Command.toKebab](Command.md#tokebab) |
|
|
26
|
+
| <a id="property-args"></a> `args?` | [`Args`](Args.md) \| `Record`\<`string`, `any`\> | see [Command.args](Command.md#property-args) |
|
|
27
|
+
| <a id="property-commandname"></a> `commandName?` | `string` | see LazyCommand.commandName |
|
|
28
|
+
| <a id="property-description"></a> `description?` | `string` | see [Command.description](Command.md#property-description) |
|
|
29
|
+
| <a id="property-entry"></a> `entry?` | `boolean` | see [Command.entry](Command.md#property-entry) |
|
|
30
|
+
| <a id="property-examples"></a> `examples?` | `string` \| (...`args`) => `any` | see [Command.examples](Command.md#property-examples) |
|
|
31
|
+
| <a id="property-internal"></a> `internal?` | `boolean` | see [Command.internal](Command.md#property-internal) |
|
|
32
|
+
| <a id="property-name"></a> `name?` | `string` | see [Command.name](Command.md#property-name) |
|
|
33
|
+
| <a id="property-rendering"></a> `rendering?` | `any` | see [Command.rendering](Command.md#property-rendering) |
|
|
34
|
+
| <a id="property-run"></a> `run?` | (...`args`) => `any` | see [Command.run](Command.md#property-run) |
|
|
35
|
+
| <a id="property-subcommands"></a> `subCommands?` | `Record`\<`string`, `any`\> \| `Map`\<`string`, `any`\> | Nested sub-commands for this command. **See** [Command.subCommands](Command.md#property-subcommands) **Since** v0.28.0 |
|
|
36
|
+
| <a id="property-tokebab"></a> `toKebab?` | `boolean` | see [Command.toKebab](Command.md#property-tokebab) |
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
type ExtendContext = Record<string, unknown>;
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
Extend command context type. This type is used to extend the command context with additional properties at [`CommandContext.extensions`](../interfaces/CommandContext.md#extensions).
|
|
9
|
+
Extend command context type. This type is used to extend the command context with additional properties at [`CommandContext.extensions`](../interfaces/CommandContext.md#property-extensions).
|
|
10
10
|
|
|
11
11
|
## Since
|
|
12
12
|
|