@alcyone-labs/arg-parser 2.14.2 → 3.0.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 +20 -127
- package/dist/config/plugins/index.d.ts +36 -4
- package/dist/config/plugins/index.d.ts.map +1 -1
- package/dist/core/ArgParser.d.ts +124 -464
- package/dist/core/ArgParser.d.ts.map +1 -1
- package/dist/core/FlagManager.d.ts +36 -136
- package/dist/core/FlagManager.d.ts.map +1 -1
- package/dist/core/PromptManager.d.ts +42 -91
- package/dist/core/PromptManager.d.ts.map +1 -1
- package/dist/core/log-path-utils.d.ts +28 -36
- package/dist/core/log-path-utils.d.ts.map +1 -1
- package/dist/core/types.d.ts +83 -592
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.cjs +599 -9658
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +26 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.min.mjs +615 -8224
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +581 -8881
- package/dist/index.mjs.map +1 -1
- package/dist/plugin/types.d.ts +121 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/utils/debug-utils.d.ts +4 -26
- package/dist/utils/debug-utils.d.ts.map +1 -1
- package/package.json +12 -73
- package/dist/assets/.dxtignore.template +0 -37
- package/dist/assets/logo_1_small.jpg +0 -0
- package/dist/config/ConfigurationManager.d.ts +0 -82
- package/dist/config/ConfigurationManager.d.ts.map +0 -1
- package/dist/config/plugins/ConfigPlugin.d.ts +0 -60
- package/dist/config/plugins/ConfigPlugin.d.ts.map +0 -1
- package/dist/config/plugins/ConfigPluginRegistry.d.ts +0 -72
- package/dist/config/plugins/ConfigPluginRegistry.d.ts.map +0 -1
- package/dist/config/plugins/TomlConfigPlugin.d.ts +0 -30
- package/dist/config/plugins/TomlConfigPlugin.d.ts.map +0 -1
- package/dist/config/plugins/YamlConfigPlugin.d.ts +0 -29
- package/dist/config/plugins/YamlConfigPlugin.d.ts.map +0 -1
- package/dist/core/ArgParserBase.d.ts +0 -319
- package/dist/core/ArgParserBase.d.ts.map +0 -1
- package/dist/core/dxt-path-resolver.d.ts +0 -100
- package/dist/core/dxt-path-resolver.d.ts.map +0 -1
- package/dist/dxt/DxtGenerator-testUtils.d.ts +0 -22
- package/dist/dxt/DxtGenerator-testUtils.d.ts.map +0 -1
- package/dist/dxt/DxtGenerator.d.ts +0 -120
- package/dist/dxt/DxtGenerator.d.ts.map +0 -1
- package/dist/mcp/ArgParserMcp.d.ts +0 -21
- package/dist/mcp/ArgParserMcp.d.ts.map +0 -1
- package/dist/mcp/mcp-integration.d.ts +0 -86
- package/dist/mcp/mcp-integration.d.ts.map +0 -1
- package/dist/mcp/mcp-lifecycle.d.ts +0 -163
- package/dist/mcp/mcp-lifecycle.d.ts.map +0 -1
- package/dist/mcp/mcp-notifications.d.ts +0 -132
- package/dist/mcp/mcp-notifications.d.ts.map +0 -1
- package/dist/mcp/mcp-prompts.d.ts +0 -132
- package/dist/mcp/mcp-prompts.d.ts.map +0 -1
- package/dist/mcp/mcp-protocol-versions.d.ts +0 -150
- package/dist/mcp/mcp-protocol-versions.d.ts.map +0 -1
- package/dist/mcp/mcp-resources.d.ts +0 -133
- package/dist/mcp/mcp-resources.d.ts.map +0 -1
- package/dist/mcp/mcp-utils.d.ts +0 -20
- package/dist/mcp/mcp-utils.d.ts.map +0 -1
- package/dist/mcp/zod-compatibility.d.ts +0 -74
- package/dist/mcp/zod-compatibility.d.ts.map +0 -1
- package/dist/testing/fuzzy-test-cli.d.ts +0 -5
- package/dist/testing/fuzzy-test-cli.d.ts.map +0 -1
- package/dist/testing/fuzzy-tester.d.ts +0 -101
- package/dist/testing/fuzzy-tester.d.ts.map +0 -1
- package/dist/tui/index.d.ts +0 -281
- package/dist/tui/types.d.ts +0 -60
- package/dist/tui/types.d.ts.map +0 -1
- package/dist/tui.cjs +0 -1060
- package/dist/tui.cjs.map +0 -1
- package/dist/tui.mjs +0 -967
- package/dist/tui.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArgParser.d.ts","sourceRoot":"","sources":["../../src/core/ArgParser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ArgParser.d.ts","sourceRoot":"","sources":["../../src/core/ArgParser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,KAAK,EACV,KAAK,EACL,eAAe,EACf,WAAW,EAEX,aAAa,EACb,UAAU,EACV,gBAAgB,EAEjB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IAK9B,QAAQ,EAAE,MAAM,EAAE;IAJpB,YAAY,EAAE,MAAM,EAAE,CAAC;gBAG5B,OAAO,EAAE,MAAM,EACR,QAAQ,GAAE,MAAM,EAAO;CAMjC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,cAAc,GAAG,GAAG;IACpD,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uBAAuB;IACvB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACvF,kBAAkB;IAClB,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;IAC5B,gDAAgD;IAChD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oCAAoC;IACpC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,sCAAsC;IACtC,sBAA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CAAC,gBAAgB;IAuBxB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IA2BjC;;OAEG;IACH,OAAO,CAAC,UAAU;IAkBlB;;OAEG;IACH,QAAQ,IAAI,MAAM;CAyCnB"}
|
|
@@ -1,174 +1,74 @@
|
|
|
1
|
-
import type { IFlag, ProcessedFlag } from "./types";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* FlagManager - Manages flag definitions and collision detection
|
|
3
|
+
*
|
|
4
|
+
* This class handles the registration, storage, and retrieval of CLI flags.
|
|
5
|
+
* It provides collision detection to prevent duplicate flag definitions.
|
|
4
6
|
*/
|
|
7
|
+
import { type IFlag, type ProcessedFlag } from "./types";
|
|
5
8
|
export interface FlagManagerOptions {
|
|
6
|
-
/**
|
|
9
|
+
/** Throw an error if a flag is added more than once */
|
|
7
10
|
throwForDuplicateFlags?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Whether to detect and report collisions between flag option strings (e.g., two flags both using `-f` or `--file`).
|
|
10
|
-
* When enabled, adding a flag with an option string that conflicts with an existing flag will trigger a warning or error.
|
|
11
|
-
* @default true
|
|
12
|
-
*/
|
|
13
|
-
detectOptionCollisions?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Whether to throw an error when flag option collisions are detected.
|
|
16
|
-
* If false, a warning is logged but the flag is still added.
|
|
17
|
-
* Only applies when detectOptionCollisions is true.
|
|
18
|
-
* @default false
|
|
19
|
-
*/
|
|
20
|
-
throwForOptionCollisions?: boolean;
|
|
21
11
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Represents a collision between flag option strings.
|
|
24
|
-
*/
|
|
25
12
|
export interface FlagOptionCollision {
|
|
26
|
-
|
|
13
|
+
flagName: string;
|
|
27
14
|
option: string;
|
|
28
|
-
/** The name of the flag that was already registered with this option */
|
|
29
15
|
existingFlagName: string;
|
|
30
|
-
/** The name of the flag being added that causes the collision */
|
|
31
|
-
newFlagName: string;
|
|
32
16
|
}
|
|
33
17
|
/**
|
|
34
|
-
* Manages flag definitions
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* const manager = new FlagManager({
|
|
39
|
-
* throwForDuplicateFlags: true,
|
|
40
|
-
* detectOptionCollisions: true,
|
|
41
|
-
* throwForOptionCollisions: true
|
|
42
|
-
* });
|
|
43
|
-
*
|
|
44
|
-
* manager.addFlag({
|
|
45
|
-
* name: "file",
|
|
46
|
-
* options: ["-f", "--file"],
|
|
47
|
-
* type: "string"
|
|
48
|
-
* });
|
|
49
|
-
*
|
|
50
|
-
* // This will throw because "-f" is already used:
|
|
51
|
-
* manager.addFlag({
|
|
52
|
-
* name: "force",
|
|
53
|
-
* options: ["-f", "--force"],
|
|
54
|
-
* type: "boolean"
|
|
55
|
-
* });
|
|
56
|
-
* ```
|
|
18
|
+
* Manages flag definitions for an ArgParser instance
|
|
57
19
|
*/
|
|
58
20
|
export declare class FlagManager {
|
|
59
|
-
|
|
21
|
+
private flags;
|
|
22
|
+
private optionToFlagMap;
|
|
23
|
+
private options;
|
|
24
|
+
constructor(options?: FlagManagerOptions, initialFlags?: readonly IFlag[]);
|
|
60
25
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* @param options - Configuration options for the manager
|
|
64
|
-
* @param initialFlags - Optional array of flags to add immediately
|
|
26
|
+
* Add a single flag
|
|
65
27
|
*/
|
|
66
|
-
|
|
28
|
+
addFlag(flag: IFlag): void;
|
|
67
29
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* @param flag - The flag definition to process
|
|
71
|
-
* @returns The processed flag with resolved types
|
|
72
|
-
* @internal
|
|
30
|
+
* Add multiple flags
|
|
73
31
|
*/
|
|
74
|
-
|
|
32
|
+
addFlags(flags: readonly IFlag[]): void;
|
|
75
33
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* Detects name collisions (if throwForDuplicateFlags is true) and
|
|
79
|
-
* option string collisions (if detectOptionCollisions is true).
|
|
80
|
-
*
|
|
81
|
-
* @param flag - The flag definition to add
|
|
82
|
-
* @returns The FlagManager instance for chaining
|
|
83
|
-
* @throws {Error} If throwForDuplicateFlags is true and a flag with the same name exists
|
|
84
|
-
* @throws {Error} If throwForOptionCollisions is true and option collisions are detected
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```typescript
|
|
88
|
-
* manager.addFlag({
|
|
89
|
-
* name: "verbose",
|
|
90
|
-
* options: ["-v", "--verbose"],
|
|
91
|
-
* type: "boolean",
|
|
92
|
-
* description: "Enable verbose output"
|
|
93
|
-
* });
|
|
94
|
-
* ```
|
|
34
|
+
* Remove a flag by name
|
|
95
35
|
*/
|
|
96
|
-
|
|
36
|
+
removeFlag(name: string): boolean;
|
|
97
37
|
/**
|
|
98
|
-
*
|
|
99
|
-
* This bypasses collision detection since inherited flags are intentional.
|
|
100
|
-
*
|
|
101
|
-
* @param processedFlag - The processed flag to add
|
|
102
|
-
* @returns The FlagManager instance for chaining
|
|
103
|
-
* @internal
|
|
38
|
+
* Check if a flag exists
|
|
104
39
|
*/
|
|
105
|
-
|
|
40
|
+
hasFlag(name: string): boolean;
|
|
106
41
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* @param flags - Array of flag definitions to add
|
|
110
|
-
* @returns The FlagManager instance for chaining
|
|
42
|
+
* Get a flag by name
|
|
111
43
|
*/
|
|
112
|
-
|
|
44
|
+
getFlag(name: string): ProcessedFlag | undefined;
|
|
113
45
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* @param name - The flag name to check
|
|
117
|
-
* @returns True if the flag exists, false otherwise
|
|
46
|
+
* Get all flags as an array
|
|
118
47
|
*/
|
|
119
|
-
|
|
48
|
+
getAllFlags(): ProcessedFlag[];
|
|
120
49
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* @param name - The name of the flag to remove
|
|
124
|
-
* @returns True if the flag was removed, false if it didn't exist
|
|
50
|
+
* Get all flag names
|
|
125
51
|
*/
|
|
126
|
-
|
|
52
|
+
getFlagNames(): string[];
|
|
127
53
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
* @param name - The name of the flag to retrieve
|
|
131
|
-
* @returns The flag definition, or undefined if not found
|
|
54
|
+
* Find flag by option
|
|
132
55
|
*/
|
|
133
|
-
|
|
56
|
+
findFlagByOption(option: string): ProcessedFlag | undefined;
|
|
134
57
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* @returns An array of all registered flags
|
|
58
|
+
* Process a raw flag into a ProcessedFlag
|
|
138
59
|
*/
|
|
139
|
-
|
|
60
|
+
private processFlag;
|
|
140
61
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
* @returns An array of all flag names
|
|
62
|
+
* Internal method to set a processed flag directly (for inheritance)
|
|
144
63
|
*/
|
|
145
|
-
|
|
64
|
+
_setProcessedFlagForInheritance(flag: ProcessedFlag): void;
|
|
146
65
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* @returns A map of option strings to flag names
|
|
66
|
+
* Clear all flags
|
|
150
67
|
*/
|
|
151
|
-
|
|
68
|
+
clear(): void;
|
|
152
69
|
/**
|
|
153
|
-
*
|
|
154
|
-
* Useful for pre-validation before adding a flag.
|
|
155
|
-
*
|
|
156
|
-
* @param flag - The flag to check for collisions
|
|
157
|
-
* @returns An array of detected collisions, empty if none
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```typescript
|
|
161
|
-
* const collisions = manager.getCollisionsForFlag({
|
|
162
|
-
* name: "force",
|
|
163
|
-
* options: ["-f", "--force"],
|
|
164
|
-
* type: "boolean"
|
|
165
|
-
* });
|
|
166
|
-
*
|
|
167
|
-
* if (collisions.length > 0) {
|
|
168
|
-
* console.log("Collisions detected:", collisions);
|
|
169
|
-
* }
|
|
170
|
-
* ```
|
|
70
|
+
* Get collision report
|
|
171
71
|
*/
|
|
172
|
-
|
|
72
|
+
getCollisions(): FlagOptionCollision[];
|
|
173
73
|
}
|
|
174
74
|
//# sourceMappingURL=FlagManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlagManager.d.ts","sourceRoot":"","sources":["../../src/core/FlagManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FlagManager.d.ts","sourceRoot":"","sources":["../../src/core/FlagManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAiB,KAAK,KAAK,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAExE,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,KAAK,CAAyC;IACtD,OAAO,CAAC,eAAe,CAAkC;IACzD,OAAO,CAAC,OAAO,CAAqB;gBAExB,OAAO,GAAE,kBAAuB,EAAE,YAAY,GAAE,SAAS,KAAK,EAAO;IAYjF;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI;IA6B1B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,KAAK,EAAE,GAAG,IAAI;IAMvC;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAYjC;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIhD;;OAEG;IACH,WAAW,IAAI,aAAa,EAAE;IAI9B;;OAEG;IACH,YAAY,IAAI,MAAM,EAAE;IAIxB;;OAEG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAM3D;;OAEG;IACH,OAAO,CAAC,WAAW;IAgBnB;;OAEG;IACH,+BAA+B,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAO1D;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,aAAa,IAAI,mBAAmB,EAAE;CAoBvC"}
|
|
@@ -1,113 +1,64 @@
|
|
|
1
|
-
import type { IHandlerContext, IPromptableFlag, PromptFieldConfig, PromptWhen } from "./types";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* PromptManager - Manages interactive prompts with @clack/prompts
|
|
3
|
+
*
|
|
4
|
+
* This class handles the collection and execution of interactive prompts
|
|
5
|
+
* for CLI applications.
|
|
4
6
|
*/
|
|
7
|
+
import type { IHandlerContext, IPromptableFlag } from "./types";
|
|
5
8
|
export interface PromptManagerOptions {
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
/** Called when user cancels (Ctrl+C) during prompts */
|
|
9
|
-
onCancel?: (ctx: IHandlerContext) => void | Promise<void>;
|
|
9
|
+
/** Default prompt sequence offset */
|
|
10
|
+
sequenceOffset?: number;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
export interface PromptResult {
|
|
15
|
-
/** Whether the prompts were completed successfully */
|
|
16
|
-
success: boolean;
|
|
17
|
-
/** The collected answers (flag name -> value) */
|
|
18
|
-
answers: Record<string, any>;
|
|
19
|
-
/** Whether the user cancelled */
|
|
20
|
-
cancelled: boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Manages interactive prompts using @clack/prompts.
|
|
24
|
-
*
|
|
25
|
-
* This class handles:
|
|
26
|
-
* - Collecting promptable flags and sorting them by sequence
|
|
27
|
-
* - Executing prompts in order with @clack/prompts
|
|
28
|
-
* - Validation and re-prompt loops
|
|
29
|
-
* - User cancellation (Ctrl+C)
|
|
30
|
-
* - TTY detection
|
|
31
|
-
* - Automatic defaultValue fallback
|
|
32
|
-
* - Select all/none toggle for multiselect
|
|
33
|
-
* - Conditional prompt skipping
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* const promptManager = new PromptManager({
|
|
38
|
-
* context: handlerContext,
|
|
39
|
-
* onCancel: () => console.log("Cancelled")
|
|
40
|
-
* });
|
|
41
|
-
*
|
|
42
|
-
* const result = await promptManager.executePrompts([
|
|
43
|
-
* { flag: envFlag, name: "environment" },
|
|
44
|
-
* { flag: versionFlag, name: "version" }
|
|
45
|
-
* ]);
|
|
46
|
-
*
|
|
47
|
-
* if (result.success) {
|
|
48
|
-
* console.log("Answers:", result.answers);
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
13
|
+
* Manages interactive prompts for an ArgParser instance
|
|
51
14
|
*/
|
|
52
15
|
export declare class PromptManager {
|
|
53
|
-
|
|
16
|
+
private promptableFlags;
|
|
17
|
+
private _options;
|
|
18
|
+
constructor(options?: PromptManagerOptions);
|
|
19
|
+
get sequenceOffset(): number;
|
|
54
20
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* @param options - Configuration options
|
|
21
|
+
* Register a promptable flag
|
|
58
22
|
*/
|
|
59
|
-
|
|
23
|
+
registerPromptableFlag(flag: IPromptableFlag): void;
|
|
60
24
|
/**
|
|
61
|
-
*
|
|
62
|
-
* Returns false in non-TTY environments (CI, pipes, etc.).
|
|
25
|
+
* Unregister a promptable flag
|
|
63
26
|
*/
|
|
64
|
-
|
|
27
|
+
unregisterPromptableFlag(name: string): boolean;
|
|
65
28
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @param promptWhen - The condition to check
|
|
69
|
-
* @param flags - The promptable flags to check
|
|
70
|
-
* @param args - The current parsed args
|
|
71
|
-
* @returns True if interactive mode should be triggered
|
|
29
|
+
* Check if a flag has a prompt
|
|
72
30
|
*/
|
|
73
|
-
|
|
74
|
-
flag: IPromptableFlag;
|
|
75
|
-
name: string;
|
|
76
|
-
}>, args: Record<string, any>): boolean;
|
|
31
|
+
hasPrompt(name: string): boolean;
|
|
77
32
|
/**
|
|
78
|
-
*
|
|
79
|
-
* Falls back to array order if promptSequence is not specified.
|
|
80
|
-
* Ties are broken by array order.
|
|
81
|
-
*
|
|
82
|
-
* @param flags - Array of flags to sort
|
|
83
|
-
* @returns Sorted array of flags
|
|
33
|
+
* Get all promptable flags sorted by sequence
|
|
84
34
|
*/
|
|
85
|
-
|
|
86
|
-
flag: IPromptableFlag;
|
|
87
|
-
name: string;
|
|
88
|
-
index: number;
|
|
89
|
-
}>): Array<{
|
|
90
|
-
flag: IPromptableFlag;
|
|
91
|
-
name: string;
|
|
92
|
-
index: number;
|
|
93
|
-
}>;
|
|
35
|
+
getPromptableFlags(): IPromptableFlag[];
|
|
94
36
|
/**
|
|
95
|
-
*
|
|
37
|
+
* Execute prompts for missing flags
|
|
96
38
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* @returns The initial value to use
|
|
39
|
+
* This is a placeholder implementation. The actual implementation
|
|
40
|
+
* would integrate with @clack/prompts.
|
|
100
41
|
*/
|
|
101
|
-
|
|
42
|
+
executePrompts(context: IHandlerContext, missingFlagNames: string[]): Promise<PromptResult>;
|
|
102
43
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* @param flags - Array of promptable flags with their names
|
|
106
|
-
* @returns The result of the prompt execution
|
|
44
|
+
* Clear all registered flags
|
|
107
45
|
*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
46
|
+
clear(): void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Result of executing prompts
|
|
50
|
+
*/
|
|
51
|
+
export interface PromptResult {
|
|
52
|
+
/** Collected answers */
|
|
53
|
+
answers: Record<string, any>;
|
|
54
|
+
/** Individual prompt results */
|
|
55
|
+
results: Array<{
|
|
56
|
+
flagName: string;
|
|
57
|
+
success: boolean;
|
|
58
|
+
value?: any;
|
|
59
|
+
error?: string;
|
|
60
|
+
}>;
|
|
61
|
+
/** Whether the user cancelled */
|
|
62
|
+
cancelled: boolean;
|
|
112
63
|
}
|
|
113
64
|
//# sourceMappingURL=PromptManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptManager.d.ts","sourceRoot":"","sources":["../../src/core/PromptManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PromptManager.d.ts","sourceRoot":"","sources":["../../src/core/PromptManager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEhE,MAAM,WAAW,oBAAoB;IACnC,qCAAqC;IACrC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,eAAe,CAA2C;IAClE,OAAO,CAAC,QAAQ,CAAuB;gBAE3B,OAAO,GAAE,oBAAyB;IAO9C,IAAI,cAAc,IAAI,MAAM,CAE3B;IAED;;OAEG;IACH,sBAAsB,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI;IAInD;;OAEG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI/C;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACH,kBAAkB,IAAI,eAAe,EAAE;IAQvC;;;;;OAKG;IACG,cAAc,CAClB,OAAO,EAAE,eAAe,EACxB,gBAAgB,EAAE,MAAM,EAAE,GACzB,OAAO,CAAC,YAAY,CAAC;IAoCxB;;OAEG;IACH,KAAK,IAAI,IAAI;CAGd;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,gCAAgC;IAChC,OAAO,EAAE,KAAK,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IACH,iCAAiC;IACjC,SAAS,EAAE,OAAO,CAAC;CACpB"}
|
|
@@ -1,59 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Log path utilities for ArgParser
|
|
3
|
+
*
|
|
4
|
+
* Provides flexible path resolution for log files, supporting
|
|
5
|
+
* relative paths (to entry point or cwd), absolute paths, and
|
|
6
|
+
* configuration objects.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Log path can be a simple string or a configuration object
|
|
10
|
+
*/
|
|
11
|
+
export type LogPath = string | LogPathConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Configuration for log path resolution
|
|
3
14
|
*/
|
|
4
15
|
export interface LogPathConfig {
|
|
5
|
-
/** The
|
|
16
|
+
/** The path string */
|
|
6
17
|
path: string;
|
|
7
|
-
/**
|
|
18
|
+
/** How to resolve the path */
|
|
8
19
|
relativeTo?: "entry" | "cwd" | "absolute";
|
|
9
|
-
/**
|
|
20
|
+
/** Optional base path for 'entry' resolution */
|
|
10
21
|
basePath?: string;
|
|
11
22
|
}
|
|
12
23
|
/**
|
|
13
|
-
*
|
|
14
|
-
*/
|
|
15
|
-
export type LogPath = string | LogPathConfig;
|
|
16
|
-
/**
|
|
17
|
-
* Attempts to detect the entry point script using multiple methods
|
|
18
|
-
* @returns The detected entry point path or null if detection fails
|
|
24
|
+
* Detect the entry point of the application
|
|
19
25
|
*/
|
|
20
|
-
export declare function detectEntryPoint(): string
|
|
26
|
+
export declare function detectEntryPoint(): string;
|
|
21
27
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @param importMetaUrl The import.meta.url value
|
|
24
|
-
* @returns The file path
|
|
28
|
+
* Get entry point from import.meta.url
|
|
25
29
|
*/
|
|
26
30
|
export declare function getEntryPointFromImportMeta(importMetaUrl: string): string;
|
|
27
31
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param logPath The log path configuration (string or object)
|
|
30
|
-
* @param fallbackEntryPoint Optional fallback entry point if detection fails
|
|
31
|
-
* @returns Absolute path to the log file
|
|
32
|
+
* Resolve a log path to an absolute path
|
|
32
33
|
*/
|
|
33
|
-
export declare function resolveLogPath(logPath: LogPath
|
|
34
|
+
export declare function resolveLogPath(logPath: LogPath): string;
|
|
34
35
|
/**
|
|
35
|
-
*
|
|
36
|
-
* @param path The relative path from the entry point
|
|
37
|
-
* @returns LogPathConfig object
|
|
36
|
+
* Create a path relative to the entry point
|
|
38
37
|
*/
|
|
39
|
-
export declare function entryRelative(
|
|
38
|
+
export declare function entryRelative(subPath: string): string;
|
|
40
39
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @param path The relative path from process.cwd()
|
|
43
|
-
* @returns LogPathConfig object
|
|
40
|
+
* Create a path relative to the current working directory
|
|
44
41
|
*/
|
|
45
|
-
export declare function cwdRelative(
|
|
42
|
+
export declare function cwdRelative(subPath: string): string;
|
|
46
43
|
/**
|
|
47
|
-
*
|
|
48
|
-
* @param path The absolute path or relative path
|
|
49
|
-
* @param basePath Optional base path to resolve relative paths against
|
|
50
|
-
* @returns LogPathConfig object
|
|
44
|
+
* Create an absolute path
|
|
51
45
|
*/
|
|
52
|
-
export declare function absolutePath(
|
|
46
|
+
export declare function absolutePath(pathStr: string): string;
|
|
53
47
|
/**
|
|
54
|
-
*
|
|
55
|
-
* @param path The path that was previously relative to cwd
|
|
56
|
-
* @returns String with explicit cwd: prefix
|
|
48
|
+
* Legacy cwd-relative path (for backward compatibility)
|
|
57
49
|
*/
|
|
58
|
-
export declare function legacyCwdPath(
|
|
50
|
+
export declare function legacyCwdPath(subPath: string): string;
|
|
59
51
|
//# sourceMappingURL=log-path-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-path-utils.d.ts","sourceRoot":"","sources":["../../src/core/log-path-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"log-path-utils.d.ts","sourceRoot":"","sources":["../../src/core/log-path-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,UAAU,CAAC;IAC1C,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAQzC;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAOzE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAsCvD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIrD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD"}
|