@guanghechen/commander 4.7.0 → 4.7.2

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.
@@ -65,9 +65,9 @@ interface ICommandOptionConfig<T = unknown> {
65
65
  apply?: (value: T, ctx: ICommandContext) => void;
66
66
  }
67
67
  /** Argument kind */
68
- type ICommandArgumentKind = 'required' | 'optional' | 'variadic';
68
+ type ICommandArgumentKind = 'required' | 'optional' | 'variadic' | 'some';
69
69
  /** Argument value type */
70
- type ICommandArgumentType = 'string' | 'number';
70
+ type ICommandArgumentType = 'string' | 'choice';
71
71
  /**
72
72
  * Positional argument configuration.
73
73
  *
@@ -85,15 +85,17 @@ interface ICommandArgumentConfig<T = unknown> {
85
85
  desc: string;
86
86
  /** Argument kind: required / optional / variadic */
87
87
  kind: ICommandArgumentKind;
88
- /** Value type, defaults to 'string' */
89
- type?: ICommandArgumentType;
88
+ /** Value type */
89
+ type: ICommandArgumentType;
90
+ /** Allowed values for choice type */
91
+ choices?: ReadonlyArray<string>;
90
92
  /** Default value when not provided (only for optional arguments) */
91
93
  default?: T;
92
94
  /** Custom value transformation (takes precedence over type conversion) */
93
95
  coerce?: (rawValue: string) => T;
94
96
  }
95
97
  interface ICommandBuiltinOptionConfig {
96
- /** Enable built-in --version option (root only, requires configured version) */
98
+ /** Enable built-in --version option (requires configured version on target command) */
97
99
  version?: boolean;
98
100
  /** Enable built-in --color/--no-color option for help rendering (defaults respect NO_COLOR) */
99
101
  color?: boolean;
@@ -317,6 +319,11 @@ interface IHelpOptionLine {
317
319
  sig: string;
318
320
  desc: string;
319
321
  }
322
+ /** Help argument line (internal) */
323
+ interface IHelpArgumentLine {
324
+ sig: string;
325
+ desc: string;
326
+ }
320
327
  /** Help command line (internal) */
321
328
  interface IHelpCommandLine {
322
329
  name: string;
@@ -332,6 +339,7 @@ interface IHelpExampleLine {
332
339
  interface IHelpData {
333
340
  desc: string;
334
341
  usage: string;
342
+ arguments: IHelpArgumentLine[];
335
343
  options: IHelpOptionLine[];
336
344
  commands: IHelpCommandLine[];
337
345
  examples: IHelpExampleLine[];
@@ -361,6 +369,17 @@ interface ICompletionOptionMeta {
361
369
  /** Allowed values */
362
370
  choices?: string[];
363
371
  }
372
+ /** Argument metadata for completion */
373
+ interface ICompletionArgumentMeta {
374
+ /** Argument name */
375
+ name: string;
376
+ /** Argument kind */
377
+ kind: ICommandArgumentKind;
378
+ /** Argument type */
379
+ type: ICommandArgumentType;
380
+ /** Allowed values (only for type='choice') */
381
+ choices?: string[];
382
+ }
364
383
  /** Command metadata for completion */
365
384
  interface ICompletionMeta {
366
385
  /** Command name */
@@ -371,6 +390,8 @@ interface ICompletionMeta {
371
390
  aliases: string[];
372
391
  /** Options */
373
392
  options: ICompletionOptionMeta[];
393
+ /** Positional arguments */
394
+ arguments: ICompletionArgumentMeta[];
374
395
  /** Subcommands */
375
396
  subcommands: ICompletionMeta[];
376
397
  }
@@ -601,4 +622,4 @@ declare class PwshCompletion {
601
622
  }
602
623
 
603
624
  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 };
625
+ 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.0",
3
+ "version": "4.7.2",
4
4
  "description": "A minimal, type-safe command-line interface builder with fluent API",
5
5
  "author": {
6
6
  "name": "guanghechen",
@@ -44,8 +44,8 @@
44
44
  "README.md"
45
45
  ],
46
46
  "dependencies": {
47
- "@guanghechen/reporter": "^3.3.0",
48
- "@guanghechen/env": "^2.0.2"
47
+ "@guanghechen/env": "^2.0.2",
48
+ "@guanghechen/reporter": "^3.3.0"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "rollup -c ../../rollup.config.mjs",