clap-ts 0.2.0 → 0.3.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 +718 -102
- package/dist/argfile.d.ts +55 -0
- package/dist/argfile.js +155 -0
- package/dist/completions.d.ts +4 -1
- package/dist/completions.js +199 -16
- package/dist/config.d.ts +75 -0
- package/dist/config.js +134 -0
- package/dist/help.d.ts +4 -4
- package/dist/help.js +276 -81
- package/dist/index.d.ts +2 -3
- package/dist/index.js +3 -3
- package/dist/install.d.ts +55 -0
- package/dist/install.js +185 -0
- package/dist/log.d.ts +78 -0
- package/dist/log.js +164 -0
- package/dist/man.d.ts +28 -0
- package/dist/man.js +234 -0
- package/dist/markdown.d.ts +17 -0
- package/dist/markdown.js +165 -0
- package/dist/output.d.ts +111 -0
- package/dist/output.js +356 -0
- package/dist/parser.d.ts +40 -19
- package/dist/parser.js +789 -461
- package/dist/plugins.d.ts +58 -0
- package/dist/plugins.js +145 -0
- package/dist/progress.d.ts +89 -0
- package/dist/progress.js +205 -0
- package/dist/prompt.d.ts +99 -0
- package/dist/prompt.js +299 -0
- package/dist/runner.d.ts +5 -2
- package/dist/runner.js +341 -135
- package/dist/spec.d.ts +83 -0
- package/dist/spec.js +124 -0
- package/dist/testing.d.ts +59 -0
- package/dist/testing.js +113 -0
- package/dist/types.d.ts +279 -11
- package/dist/validation.js +191 -69
- package/package.json +63 -6
package/dist/parser.d.ts
CHANGED
|
@@ -1,32 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Argument parser
|
|
3
|
-
* then layers on: env fallback, type coercion, count/append actions,
|
|
4
|
-
* numArgs with defaultMissingValue, global args, kebab-to-camel mapping,
|
|
5
|
-
* subcommand detection, and default values.
|
|
2
|
+
* Argument parser.
|
|
6
3
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* Tokenizes argv directly against the command's own arg definitions. This
|
|
5
|
+
* replaced node:util parseArgs, which re-validates its entire `options` object
|
|
6
|
+
* on every call (~170ns per option, regardless of argv length) and cannot
|
|
7
|
+
* express multi-value options, value terminators, or subcommand boundaries.
|
|
10
8
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
9
|
+
* Handled here: long/short/clustered flags, attached and `=` values, boolean
|
|
10
|
+
* negation, count and append actions, multi-token numArgs, optional values via
|
|
11
|
+
* defaultMissingValue, value delimiters, hyphen and negative-number values,
|
|
12
|
+
* positional assignment, trailing var args, `--` escape, subcommand
|
|
13
|
+
* boundaries, env fallback, conditional and static defaults, and
|
|
14
|
+
* kebab-to-camel key mapping.
|
|
15
|
+
*
|
|
16
|
+
* Constraint checks that need the whole picture (conflicts, requires, groups,
|
|
17
|
+
* possible values) live in validation.ts.
|
|
19
18
|
*/
|
|
20
|
-
import type { ArgsDef, ParseResult, CommandDef } from './types.js';
|
|
21
|
-
/** Get the raw argv slice (after the binary/script path). */
|
|
22
|
-
export declare function getRawArgs(argv?: readonly string[]): string[];
|
|
19
|
+
import type { ArgDef, ArgsDef, ParseResult, CommandDef, PossibleValue } from './types.js';
|
|
23
20
|
export declare class CliParseError extends Error {
|
|
24
21
|
constructor(message: string);
|
|
25
22
|
}
|
|
23
|
+
/** Convert kebab-case to camelCase: --config-path -> configPath */
|
|
24
|
+
export declare function kebabToCamel(s: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Get the raw argv slice (after the binary/script path). With `noBinaryName`
|
|
27
|
+
* the source is taken as-is, matching clap's Command::no_binary_name.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getRawArgs(argv?: readonly string[], noBinaryName?: boolean): string[];
|
|
30
|
+
/**
|
|
31
|
+
* The command's subcommands, building any lazy ones on first use and caching
|
|
32
|
+
* the result so the thunk runs at most once per command.
|
|
33
|
+
*/
|
|
34
|
+
export declare function subCommandsOf(command: CommandDef<any>): Record<string, CommandDef<any>>;
|
|
35
|
+
/** Whether the command has any subcommand, without building the lazy ones. */
|
|
36
|
+
export declare function hasSubCommands(command: CommandDef<any>): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Normalize an arg's allowed values to PossibleValue records. Plain strings and
|
|
39
|
+
* PossibleValue objects can be mixed in the same list.
|
|
40
|
+
*/
|
|
41
|
+
export declare function possibleValues(def: ArgDef): readonly PossibleValue[];
|
|
42
|
+
/** Whether a raw value matches this possible value, by name or alias. */
|
|
43
|
+
export declare function matchesPossibleValue(candidate: PossibleValue, value: string, ignoreCase: boolean): boolean;
|
|
44
|
+
export declare function coerceValue(value: string, def: ArgDef, argName: string): string | number | boolean;
|
|
26
45
|
/**
|
|
27
46
|
* Parse raw argument tokens against a command definition.
|
|
28
47
|
*
|
|
29
|
-
*
|
|
48
|
+
* Stops at the first bare token matching a subcommand name or alias; the
|
|
49
|
+
* remaining tokens are returned as `subCommandArgs` for the caller to parse
|
|
50
|
+
* against that subcommand.
|
|
30
51
|
*/
|
|
31
52
|
export declare function parseArgs(rawArgs: readonly string[], command: CommandDef): ParseResult;
|
|
32
53
|
/**
|