@optique/core 1.1.0-dev.2096 → 1.1.0-dev.2146
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/dist/annotation-state.cjs +26 -26
- package/dist/annotation-state.d.cts +133 -1
- package/dist/annotation-state.d.ts +133 -1
- package/dist/annotations.cjs +2 -2
- package/dist/constructs.cjs +141 -73
- package/dist/constructs.js +70 -2
- package/dist/dependency-metadata.cjs +12 -12
- package/dist/dependency-metadata.d.cts +34 -3
- package/dist/dependency-metadata.d.ts +34 -3
- package/dist/dependency-runtime.cjs +37 -13
- package/dist/dependency-runtime.d.cts +197 -2
- package/dist/dependency-runtime.d.ts +197 -2
- package/dist/dependency-runtime.js +22 -1
- package/dist/dependency.cjs +7 -7
- package/dist/displaywidth.d.cts +12 -0
- package/dist/displaywidth.d.ts +12 -0
- package/dist/execution-context.d.cts +23 -0
- package/dist/execution-context.d.ts +23 -0
- package/dist/extension.cjs +14 -14
- package/dist/facade.cjs +46 -36
- package/dist/facade.js +31 -21
- package/dist/index.cjs +22 -21
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/input-trace.d.cts +2 -1
- package/dist/input-trace.d.ts +2 -1
- package/dist/internal/annotations.cjs +3 -0
- package/dist/internal/annotations.d.cts +47 -5
- package/dist/internal/annotations.d.ts +47 -5
- package/dist/internal/annotations.js +1 -1
- package/dist/internal/command-alias.cjs +16 -0
- package/dist/internal/command-alias.js +14 -0
- package/dist/internal/dependency.cjs +131 -0
- package/dist/internal/dependency.d.cts +311 -2
- package/dist/internal/dependency.d.ts +311 -2
- package/dist/internal/dependency.js +119 -1
- package/dist/internal/parser.cjs +35 -13
- package/dist/internal/parser.d.cts +44 -3
- package/dist/internal/parser.d.ts +44 -3
- package/dist/internal/parser.js +28 -6
- package/dist/modifiers.cjs +41 -41
- package/dist/parser.cjs +11 -11
- package/dist/phase2-seed.cjs +2 -2
- package/dist/phase2-seed.d.cts +50 -0
- package/dist/phase2-seed.d.ts +50 -0
- package/dist/primitives.cjs +74 -33
- package/dist/primitives.d.cts +10 -0
- package/dist/primitives.d.ts +10 -0
- package/dist/primitives.js +54 -13
- package/dist/suggestion.cjs +72 -2
- package/dist/suggestion.d.cts +188 -0
- package/dist/suggestion.d.ts +188 -0
- package/dist/suggestion.js +71 -3
- package/dist/usage-internals.cjs +5 -1
- package/dist/usage-internals.js +5 -1
- package/dist/usage.cjs +9 -1
- package/dist/usage.d.cts +14 -0
- package/dist/usage.d.ts +14 -0
- package/dist/usage.js +9 -1
- package/dist/validate.cjs +1 -0
- package/dist/validate.d.cts +99 -0
- package/dist/validate.d.ts +99 -0
- package/dist/validate.js +1 -1
- package/dist/valueparser.cjs +333 -79
- package/dist/valueparser.d.cts +197 -1
- package/dist/valueparser.d.ts +197 -1
- package/dist/valueparser.js +334 -81
- package/package.json +19 -4
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
//#region src/validate.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Escapes control characters in a string for readable error messages.
|
|
4
|
+
*
|
|
5
|
+
* @param value The string to escape.
|
|
6
|
+
* @returns The escaped string with control characters replaced by escape
|
|
7
|
+
* sequences.
|
|
8
|
+
*/
|
|
9
|
+
declare function escapeControlChars(value: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Validates option names at runtime.
|
|
12
|
+
*
|
|
13
|
+
* @param names The option names to validate.
|
|
14
|
+
* @param label A human-readable label for error messages (e.g.,
|
|
15
|
+
* `"Option"`, `"Flag"`, `"Help option"`).
|
|
16
|
+
* @throws {TypeError} If the names array is empty, or any name is empty,
|
|
17
|
+
* lacks a valid prefix, or contains whitespace or control characters.
|
|
18
|
+
*/
|
|
19
|
+
declare function validateOptionNames(names: readonly string[], label: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Validates command names at runtime.
|
|
22
|
+
*
|
|
23
|
+
* @param names The command names to validate.
|
|
24
|
+
* @param label A human-readable label for error messages (e.g.,
|
|
25
|
+
* `"Help command"`).
|
|
26
|
+
* @throws {TypeError} If the names array is empty, or any name is empty,
|
|
27
|
+
* whitespace-only, or contains whitespace or control characters.
|
|
28
|
+
*/
|
|
29
|
+
declare function validateCommandNames(names: readonly string[], label: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* A meta entry describes one active meta feature for collision checking.
|
|
32
|
+
*
|
|
33
|
+
* The tuple elements are:
|
|
34
|
+
*
|
|
35
|
+
* 1. `kind` — `"command"` if this meta feature matches at `args[0]` only,
|
|
36
|
+
* or `"option"` if a lenient scanner matches the name anywhere in `argv`.
|
|
37
|
+
* 2. `label` — human-readable label for error messages (e.g., `"help option"`).
|
|
38
|
+
* 3. `names` — the configured name(s) for this meta feature.
|
|
39
|
+
* 4. `prefixMatch` — when `true`, the runtime also intercepts tokens
|
|
40
|
+
* starting with `name=` (e.g., `--completion=bash`). Only the
|
|
41
|
+
* completion option uses this form; help/version use exact matching.
|
|
42
|
+
*
|
|
43
|
+
* @since 1.0.0
|
|
44
|
+
*/
|
|
45
|
+
type MetaEntry = readonly [kind: "command" | "option", label: string, names: readonly string[], prefixMatch?: boolean];
|
|
46
|
+
/**
|
|
47
|
+
* Validates that there are no name collisions among active meta features
|
|
48
|
+
* (help, version, completion).
|
|
49
|
+
*
|
|
50
|
+
* User parser names are accepted even when they overlap with meta names.
|
|
51
|
+
* Runtime parsing resolves those cases parser-first so ordinary parser data
|
|
52
|
+
* can shadow built-in meta behavior.
|
|
53
|
+
*
|
|
54
|
+
* Meta-vs-meta collisions are always checked in a unified namespace,
|
|
55
|
+
* because a meta command named `"--help"` and a meta option named
|
|
56
|
+
* `"--help"` both compete for the same token.
|
|
57
|
+
*
|
|
58
|
+
* @param metaEntries Active meta feature entries annotated with their kind.
|
|
59
|
+
* @throws {TypeError} If any meta/meta collision or duplicate is detected.
|
|
60
|
+
* @since 1.0.0
|
|
61
|
+
*/
|
|
62
|
+
declare function validateMetaNameCollisions(metaEntries: readonly MetaEntry[]): void;
|
|
63
|
+
/**
|
|
64
|
+
* Validates a program name at runtime.
|
|
65
|
+
*
|
|
66
|
+
* Program names may contain spaces (e.g., file paths), but must not be empty,
|
|
67
|
+
* whitespace-only, or contain control characters.
|
|
68
|
+
*
|
|
69
|
+
* @param programName The program name to validate.
|
|
70
|
+
* @throws {TypeError} If the value is not a string, is empty,
|
|
71
|
+
* whitespace-only, or contains control characters.
|
|
72
|
+
*/
|
|
73
|
+
declare function validateProgramName(programName: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* Validates a label at runtime.
|
|
76
|
+
*
|
|
77
|
+
* Labels are used as section titles in documentation output. They may contain
|
|
78
|
+
* spaces (e.g., "Connection options"), but must not be empty, whitespace-only,
|
|
79
|
+
* or contain control characters.
|
|
80
|
+
*
|
|
81
|
+
* @param label The label to validate.
|
|
82
|
+
* @throws {TypeError} If the label is not a string, is empty,
|
|
83
|
+
* whitespace-only, or contains control characters.
|
|
84
|
+
* @since 1.0.0
|
|
85
|
+
*/
|
|
86
|
+
declare function validateLabel(label: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Validates that all source contexts have unique
|
|
89
|
+
* {@link import("./context.ts").SourceContext.id | id} values.
|
|
90
|
+
*
|
|
91
|
+
* @param contexts The source contexts to validate.
|
|
92
|
+
* @throws {TypeError} If two or more contexts share the same id.
|
|
93
|
+
* @since 1.0.0
|
|
94
|
+
*/
|
|
95
|
+
declare function validateContextIds(contexts: readonly {
|
|
96
|
+
readonly id: symbol;
|
|
97
|
+
}[]): void;
|
|
98
|
+
//#endregion
|
|
99
|
+
export { MetaEntry, escapeControlChars, validateCommandNames, validateContextIds, validateLabel, validateMetaNameCollisions, validateOptionNames, validateProgramName };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
//#region src/validate.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Escapes control characters in a string for readable error messages.
|
|
4
|
+
*
|
|
5
|
+
* @param value The string to escape.
|
|
6
|
+
* @returns The escaped string with control characters replaced by escape
|
|
7
|
+
* sequences.
|
|
8
|
+
*/
|
|
9
|
+
declare function escapeControlChars(value: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Validates option names at runtime.
|
|
12
|
+
*
|
|
13
|
+
* @param names The option names to validate.
|
|
14
|
+
* @param label A human-readable label for error messages (e.g.,
|
|
15
|
+
* `"Option"`, `"Flag"`, `"Help option"`).
|
|
16
|
+
* @throws {TypeError} If the names array is empty, or any name is empty,
|
|
17
|
+
* lacks a valid prefix, or contains whitespace or control characters.
|
|
18
|
+
*/
|
|
19
|
+
declare function validateOptionNames(names: readonly string[], label: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Validates command names at runtime.
|
|
22
|
+
*
|
|
23
|
+
* @param names The command names to validate.
|
|
24
|
+
* @param label A human-readable label for error messages (e.g.,
|
|
25
|
+
* `"Help command"`).
|
|
26
|
+
* @throws {TypeError} If the names array is empty, or any name is empty,
|
|
27
|
+
* whitespace-only, or contains whitespace or control characters.
|
|
28
|
+
*/
|
|
29
|
+
declare function validateCommandNames(names: readonly string[], label: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* A meta entry describes one active meta feature for collision checking.
|
|
32
|
+
*
|
|
33
|
+
* The tuple elements are:
|
|
34
|
+
*
|
|
35
|
+
* 1. `kind` — `"command"` if this meta feature matches at `args[0]` only,
|
|
36
|
+
* or `"option"` if a lenient scanner matches the name anywhere in `argv`.
|
|
37
|
+
* 2. `label` — human-readable label for error messages (e.g., `"help option"`).
|
|
38
|
+
* 3. `names` — the configured name(s) for this meta feature.
|
|
39
|
+
* 4. `prefixMatch` — when `true`, the runtime also intercepts tokens
|
|
40
|
+
* starting with `name=` (e.g., `--completion=bash`). Only the
|
|
41
|
+
* completion option uses this form; help/version use exact matching.
|
|
42
|
+
*
|
|
43
|
+
* @since 1.0.0
|
|
44
|
+
*/
|
|
45
|
+
type MetaEntry = readonly [kind: "command" | "option", label: string, names: readonly string[], prefixMatch?: boolean];
|
|
46
|
+
/**
|
|
47
|
+
* Validates that there are no name collisions among active meta features
|
|
48
|
+
* (help, version, completion).
|
|
49
|
+
*
|
|
50
|
+
* User parser names are accepted even when they overlap with meta names.
|
|
51
|
+
* Runtime parsing resolves those cases parser-first so ordinary parser data
|
|
52
|
+
* can shadow built-in meta behavior.
|
|
53
|
+
*
|
|
54
|
+
* Meta-vs-meta collisions are always checked in a unified namespace,
|
|
55
|
+
* because a meta command named `"--help"` and a meta option named
|
|
56
|
+
* `"--help"` both compete for the same token.
|
|
57
|
+
*
|
|
58
|
+
* @param metaEntries Active meta feature entries annotated with their kind.
|
|
59
|
+
* @throws {TypeError} If any meta/meta collision or duplicate is detected.
|
|
60
|
+
* @since 1.0.0
|
|
61
|
+
*/
|
|
62
|
+
declare function validateMetaNameCollisions(metaEntries: readonly MetaEntry[]): void;
|
|
63
|
+
/**
|
|
64
|
+
* Validates a program name at runtime.
|
|
65
|
+
*
|
|
66
|
+
* Program names may contain spaces (e.g., file paths), but must not be empty,
|
|
67
|
+
* whitespace-only, or contain control characters.
|
|
68
|
+
*
|
|
69
|
+
* @param programName The program name to validate.
|
|
70
|
+
* @throws {TypeError} If the value is not a string, is empty,
|
|
71
|
+
* whitespace-only, or contains control characters.
|
|
72
|
+
*/
|
|
73
|
+
declare function validateProgramName(programName: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* Validates a label at runtime.
|
|
76
|
+
*
|
|
77
|
+
* Labels are used as section titles in documentation output. They may contain
|
|
78
|
+
* spaces (e.g., "Connection options"), but must not be empty, whitespace-only,
|
|
79
|
+
* or contain control characters.
|
|
80
|
+
*
|
|
81
|
+
* @param label The label to validate.
|
|
82
|
+
* @throws {TypeError} If the label is not a string, is empty,
|
|
83
|
+
* whitespace-only, or contains control characters.
|
|
84
|
+
* @since 1.0.0
|
|
85
|
+
*/
|
|
86
|
+
declare function validateLabel(label: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Validates that all source contexts have unique
|
|
89
|
+
* {@link import("./context.ts").SourceContext.id | id} values.
|
|
90
|
+
*
|
|
91
|
+
* @param contexts The source contexts to validate.
|
|
92
|
+
* @throws {TypeError} If two or more contexts share the same id.
|
|
93
|
+
* @since 1.0.0
|
|
94
|
+
*/
|
|
95
|
+
declare function validateContextIds(contexts: readonly {
|
|
96
|
+
readonly id: symbol;
|
|
97
|
+
}[]): void;
|
|
98
|
+
//#endregion
|
|
99
|
+
export { MetaEntry, escapeControlChars, validateCommandNames, validateContextIds, validateLabel, validateMetaNameCollisions, validateOptionNames, validateProgramName };
|
package/dist/validate.js
CHANGED
|
@@ -161,4 +161,4 @@ function validateContextIds(contexts) {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
//#endregion
|
|
164
|
-
export { validateCommandNames, validateContextIds, validateLabel, validateMetaNameCollisions, validateOptionNames, validateProgramName };
|
|
164
|
+
export { escapeControlChars, validateCommandNames, validateContextIds, validateLabel, validateMetaNameCollisions, validateOptionNames, validateProgramName };
|