@guanghechen/commander 4.7.1 → 4.7.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.
@@ -29,13 +29,14 @@ interface ICommandToken {
29
29
  /** Option value type */
30
30
  type ICommandOptionType = 'boolean' | 'number' | 'string';
31
31
  /** Option argument mode */
32
- type ICommandOptionArgs = 'none' | 'required' | 'variadic';
32
+ type ICommandOptionArgs = 'none' | 'required' | 'optional' | 'variadic';
33
33
  /**
34
34
  * Option configuration.
35
35
  *
36
36
  * `type` and `args` must be specified together. Valid combinations:
37
37
  * - boolean + none → boolean
38
38
  * - string + required → string
39
+ * - string + optional → string | undefined
39
40
  * - number + required → number
40
41
  * - string + variadic → string[]
41
42
  * - number + variadic → number[]
@@ -65,9 +66,9 @@ interface ICommandOptionConfig<T = unknown> {
65
66
  apply?: (value: T, ctx: ICommandContext) => void;
66
67
  }
67
68
  /** Argument kind */
68
- type ICommandArgumentKind = 'required' | 'optional' | 'variadic';
69
+ type ICommandArgumentKind = 'required' | 'optional' | 'variadic' | 'some';
69
70
  /** Argument value type */
70
- type ICommandArgumentType = 'string' | 'number';
71
+ type ICommandArgumentType = 'string' | 'choice';
71
72
  /**
72
73
  * Positional argument configuration.
73
74
  *
@@ -85,8 +86,10 @@ interface ICommandArgumentConfig<T = unknown> {
85
86
  desc: string;
86
87
  /** Argument kind: required / optional / variadic */
87
88
  kind: ICommandArgumentKind;
88
- /** Value type, defaults to 'string' */
89
- type?: ICommandArgumentType;
89
+ /** Value type */
90
+ type: ICommandArgumentType;
91
+ /** Allowed values for choice type */
92
+ choices?: ReadonlyArray<string>;
90
93
  /** Default value when not provided (only for optional arguments) */
91
94
  default?: T;
92
95
  /** Custom value transformation (takes precedence over type conversion) */
@@ -317,6 +320,11 @@ interface IHelpOptionLine {
317
320
  sig: string;
318
321
  desc: string;
319
322
  }
323
+ /** Help argument line (internal) */
324
+ interface IHelpArgumentLine {
325
+ sig: string;
326
+ desc: string;
327
+ }
320
328
  /** Help command line (internal) */
321
329
  interface IHelpCommandLine {
322
330
  name: string;
@@ -332,6 +340,7 @@ interface IHelpExampleLine {
332
340
  interface IHelpData {
333
341
  desc: string;
334
342
  usage: string;
343
+ arguments: IHelpArgumentLine[];
335
344
  options: IHelpOptionLine[];
336
345
  commands: IHelpCommandLine[];
337
346
  examples: IHelpExampleLine[];
@@ -361,6 +370,17 @@ interface ICompletionOptionMeta {
361
370
  /** Allowed values */
362
371
  choices?: string[];
363
372
  }
373
+ /** Argument metadata for completion */
374
+ interface ICompletionArgumentMeta {
375
+ /** Argument name */
376
+ name: string;
377
+ /** Argument kind */
378
+ kind: ICommandArgumentKind;
379
+ /** Argument type */
380
+ type: ICommandArgumentType;
381
+ /** Allowed values (only for type='choice') */
382
+ choices?: string[];
383
+ }
364
384
  /** Command metadata for completion */
365
385
  interface ICompletionMeta {
366
386
  /** Command name */
@@ -371,6 +391,8 @@ interface ICompletionMeta {
371
391
  aliases: string[];
372
392
  /** Options */
373
393
  options: ICompletionOptionMeta[];
394
+ /** Positional arguments */
395
+ arguments: ICompletionArgumentMeta[];
374
396
  /** Subcommands */
375
397
  subcommands: ICompletionMeta[];
376
398
  }
@@ -548,4 +570,4 @@ declare function getDefaultCommandRuntime(): ICommandRuntime;
548
570
  declare function setDefaultCommandRuntime(runtime: ICommandRuntime): void;
549
571
 
550
572
  export { Coerce, Command, CommanderError, createBrowserCommandRuntime, getDefaultCommandRuntime, isDomain, isIp, isIpv4, isIpv6, logColorfulOption, logDateOption, logLevelOption, setDefaultCommandRuntime, silentOption };
551
- export type { ICommand, ICommandAction, ICommandActionParams, ICommandArgumentConfig, ICommandArgumentKind, ICommandArgumentType, ICommandBuiltinConfig, ICommandBuiltinOptionConfig, ICommandBuiltinOptionResolved, ICommandBuiltinResolved, ICommandConfig, ICommandContext, ICommandControlScanResult, ICommandControls, ICommandExample, ICommandInputSources, ICommandOptionArgs, ICommandOptionConfig, ICommandOptionType, ICommandParseResult, ICommandParsedArgs, ICommandParsedOpts, ICommandPresetConfig, ICommandPresetResult, ICommandResolveResult, ICommandRouteResult, ICommandRunParams, ICommandRuntime, ICommandRuntimeStats, ICommandShiftResult, ICommandToken, ICommandTokenType, ICommandTokenizeResult, ICommanderErrorKind, ICompletionCommandConfig, ICompletionMeta, ICompletionOptionMeta, ICompletionPaths, ICompletionShellType, IHelpCommandLine, IHelpData, IHelpExampleLine, IHelpOptionLine, ISubcommandEntry };
573
+ export type { ICommand, ICommandAction, ICommandActionParams, ICommandArgumentConfig, ICommandArgumentKind, ICommandArgumentType, ICommandBuiltinConfig, ICommandBuiltinOptionConfig, ICommandBuiltinOptionResolved, ICommandBuiltinResolved, ICommandConfig, ICommandContext, ICommandControlScanResult, ICommandControls, ICommandExample, ICommandInputSources, ICommandOptionArgs, ICommandOptionConfig, ICommandOptionType, ICommandParseResult, ICommandParsedArgs, ICommandParsedOpts, ICommandPresetConfig, ICommandPresetResult, ICommandResolveResult, ICommandRouteResult, ICommandRunParams, ICommandRuntime, ICommandRuntimeStats, ICommandShiftResult, ICommandToken, ICommandTokenType, ICommandTokenizeResult, ICommanderErrorKind, ICompletionArgumentMeta, ICompletionCommandConfig, ICompletionMeta, ICompletionOptionMeta, ICompletionPaths, ICompletionShellType, IHelpArgumentLine, IHelpCommandLine, IHelpData, IHelpExampleLine, IHelpOptionLine, ISubcommandEntry };
@@ -29,13 +29,14 @@ interface ICommandToken {
29
29
  /** Option value type */
30
30
  type ICommandOptionType = 'boolean' | 'number' | 'string';
31
31
  /** Option argument mode */
32
- type ICommandOptionArgs = 'none' | 'required' | 'variadic';
32
+ type ICommandOptionArgs = 'none' | 'required' | 'optional' | 'variadic';
33
33
  /**
34
34
  * Option configuration.
35
35
  *
36
36
  * `type` and `args` must be specified together. Valid combinations:
37
37
  * - boolean + none → boolean
38
38
  * - string + required → string
39
+ * - string + optional → string | undefined
39
40
  * - number + required → number
40
41
  * - string + variadic → string[]
41
42
  * - number + variadic → number[]
@@ -65,9 +66,9 @@ interface ICommandOptionConfig<T = unknown> {
65
66
  apply?: (value: T, ctx: ICommandContext) => void;
66
67
  }
67
68
  /** Argument kind */
68
- type ICommandArgumentKind = 'required' | 'optional' | 'variadic';
69
+ type ICommandArgumentKind = 'required' | 'optional' | 'variadic' | 'some';
69
70
  /** Argument value type */
70
- type ICommandArgumentType = 'string' | 'number';
71
+ type ICommandArgumentType = 'string' | 'choice';
71
72
  /**
72
73
  * Positional argument configuration.
73
74
  *
@@ -85,8 +86,10 @@ interface ICommandArgumentConfig<T = unknown> {
85
86
  desc: string;
86
87
  /** Argument kind: required / optional / variadic */
87
88
  kind: ICommandArgumentKind;
88
- /** Value type, defaults to 'string' */
89
- type?: ICommandArgumentType;
89
+ /** Value type */
90
+ type: ICommandArgumentType;
91
+ /** Allowed values for choice type */
92
+ choices?: ReadonlyArray<string>;
90
93
  /** Default value when not provided (only for optional arguments) */
91
94
  default?: T;
92
95
  /** Custom value transformation (takes precedence over type conversion) */
@@ -317,6 +320,11 @@ interface IHelpOptionLine {
317
320
  sig: string;
318
321
  desc: string;
319
322
  }
323
+ /** Help argument line (internal) */
324
+ interface IHelpArgumentLine {
325
+ sig: string;
326
+ desc: string;
327
+ }
320
328
  /** Help command line (internal) */
321
329
  interface IHelpCommandLine {
322
330
  name: string;
@@ -332,6 +340,7 @@ interface IHelpExampleLine {
332
340
  interface IHelpData {
333
341
  desc: string;
334
342
  usage: string;
343
+ arguments: IHelpArgumentLine[];
335
344
  options: IHelpOptionLine[];
336
345
  commands: IHelpCommandLine[];
337
346
  examples: IHelpExampleLine[];
@@ -361,6 +370,17 @@ interface ICompletionOptionMeta {
361
370
  /** Allowed values */
362
371
  choices?: string[];
363
372
  }
373
+ /** Argument metadata for completion */
374
+ interface ICompletionArgumentMeta {
375
+ /** Argument name */
376
+ name: string;
377
+ /** Argument kind */
378
+ kind: ICommandArgumentKind;
379
+ /** Argument type */
380
+ type: ICommandArgumentType;
381
+ /** Allowed values (only for type='choice') */
382
+ choices?: string[];
383
+ }
364
384
  /** Command metadata for completion */
365
385
  interface ICompletionMeta {
366
386
  /** Command name */
@@ -371,6 +391,8 @@ interface ICompletionMeta {
371
391
  aliases: string[];
372
392
  /** Options */
373
393
  options: ICompletionOptionMeta[];
394
+ /** Positional arguments */
395
+ arguments: ICompletionArgumentMeta[];
374
396
  /** Subcommands */
375
397
  subcommands: ICompletionMeta[];
376
398
  }
@@ -601,4 +623,4 @@ declare class PwshCompletion {
601
623
  }
602
624
 
603
625
  export { BashCompletion, Coerce, Command, CommanderError, CompletionCommand, FishCompletion, PwshCompletion, createBrowserCommandRuntime, createNodeCommandRuntime, getDefaultCommandRuntime, isDomain, isIp, isIpv4, isIpv6, logColorfulOption, logDateOption, logLevelOption, setDefaultCommandRuntime, silentOption };
604
- export type { ICommand, ICommandAction, ICommandActionParams, ICommandArgumentConfig, ICommandArgumentKind, ICommandArgumentType, ICommandBuiltinConfig, ICommandBuiltinOptionConfig, ICommandBuiltinOptionResolved, ICommandBuiltinResolved, ICommandConfig, ICommandContext, ICommandControlScanResult, ICommandControls, ICommandExample, ICommandInputSources, ICommandOptionArgs, ICommandOptionConfig, ICommandOptionType, ICommandParseResult, ICommandParsedArgs, ICommandParsedOpts, ICommandPresetConfig, ICommandPresetResult, ICommandResolveResult, ICommandRouteResult, ICommandRunParams, ICommandRuntime, ICommandRuntimeStats, ICommandShiftResult, ICommandToken, ICommandTokenType, ICommandTokenizeResult, ICommanderErrorKind, ICompletionCommandConfig, ICompletionMeta, ICompletionOptionMeta, ICompletionPaths, ICompletionShellType, IHelpCommandLine, IHelpData, IHelpExampleLine, IHelpOptionLine, ISubcommandEntry };
626
+ export type { ICommand, ICommandAction, ICommandActionParams, ICommandArgumentConfig, ICommandArgumentKind, ICommandArgumentType, ICommandBuiltinConfig, ICommandBuiltinOptionConfig, ICommandBuiltinOptionResolved, ICommandBuiltinResolved, ICommandConfig, ICommandContext, ICommandControlScanResult, ICommandControls, ICommandExample, ICommandInputSources, ICommandOptionArgs, ICommandOptionConfig, ICommandOptionType, ICommandParseResult, ICommandParsedArgs, ICommandParsedOpts, ICommandPresetConfig, ICommandPresetResult, ICommandResolveResult, ICommandRouteResult, ICommandRunParams, ICommandRuntime, ICommandRuntimeStats, ICommandShiftResult, ICommandToken, ICommandTokenType, ICommandTokenizeResult, ICommanderErrorKind, ICompletionArgumentMeta, ICompletionCommandConfig, ICompletionMeta, ICompletionOptionMeta, ICompletionPaths, ICompletionShellType, IHelpArgumentLine, IHelpCommandLine, IHelpData, IHelpExampleLine, IHelpOptionLine, ISubcommandEntry };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guanghechen/commander",
3
- "version": "4.7.1",
3
+ "version": "4.7.3",
4
4
  "description": "A minimal, type-safe command-line interface builder with fluent API",
5
5
  "author": {
6
6
  "name": "guanghechen",