@politty/zod 0.2.4 → 0.3.1
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 +29 -6
- package/dist/{arg-registry-C-fvuAAg.d.ts → arg-registry-DdEs3jd0.d.ts} +8 -2
- package/dist/augment.d.ts +3 -2
- package/dist/{cli-main-KajE103P.js → cli-main-DWQYfxFO.js} +2 -2
- package/dist/cli-main-X_a3vjMI.js +1 -0
- package/dist/cli-run-BfhO1D3b.js +1 -0
- package/dist/cli.js +1 -1
- package/dist/compile-cache-6u9hgeWu.js +1 -0
- package/dist/compile-cache.d.ts +5 -6
- package/dist/compile-cache.js +1 -1
- package/dist/completion-CDwNvtfE.js +1 -0
- package/dist/{completion-BqYtsuso.js → completion-DwBjO-3Q.js} +5 -5
- package/dist/completion.d.ts +29 -18
- package/dist/completion.js +1 -1
- package/dist/docs.d.ts +46 -46
- package/dist/docs.js +5 -5
- package/dist/dynamic-BBr42fJH.js +1 -0
- package/dist/dynamic-BK6Tq_FR.js +6 -0
- package/dist/field-meta-D7G8a7IG.js +1 -0
- package/dist/index.d.ts +240 -52
- package/dist/index.js +1 -1
- package/dist/logger-CoeDrmRr.js +1 -0
- package/dist/prompt-clack.d.ts +3 -4
- package/dist/prompt-clack.js +1 -1
- package/dist/prompt-inquirer.d.ts +3 -4
- package/dist/prompt-inquirer.js +1 -1
- package/dist/prompt.d.ts +7 -7
- package/dist/prompt.js +1 -1
- package/dist/{register-C1WbbeYH.js → register-D0mDOOyc.js} +1 -1
- package/dist/runner-DPQ3GQA7.js +1 -0
- package/dist/runner-DtJbfhOs.js +30 -0
- package/dist/{schema-extractor-DU0Vuhbd.js → schema-extractor-QpSHJvwI.js} +1 -1
- package/dist/{schema-BiUP_KyV.js → schema-ohwvrBGz.js} +1 -1
- package/dist/skill.d.ts +13 -13
- package/dist/skill.js +1 -1
- package/dist/{with-completion-command-DMPw58_x.d.ts → with-completion-command-Bi7v_Wlq.d.ts} +1 -1
- package/dist/{with-completion-command-DM6F5LyO.js → with-completion-command-CZ9qcezN.js} +2 -2
- package/package.json +5 -5
- package/dist/cli-main-B0jMuGGi.js +0 -1
- package/dist/cli-run-Bm3vsxIB.js +0 -1
- package/dist/compile-cache-VuUbFWIo.js +0 -1
- package/dist/completion-OEWfekOk.js +0 -1
- package/dist/dynamic-D7QInkeD.js +0 -6
- package/dist/dynamic-DPbDLfHB.js +0 -1
- package/dist/field-meta-COGya7xp.js +0 -1
- package/dist/logger-CJsyJ8sb.js +0 -1
- package/dist/runner-CPganzL6.js +0 -1
- package/dist/runner-DECNQyff.js +0 -29
package/dist/completion.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Command, Z as ResolvedFieldMeta, _ as DynamicCompletionResult, b as ArgsSchema, d as ExpandCompletion, g as DynamicCompletionResolver, h as DynamicCompletionContext, m as DynamicCompletionCandidate, p as CompletionDirectiveMask, v as AnyCommand } from "./arg-registry-
|
|
2
|
-
import { _ as CompletionResult, a as bundledWorkerShellExtension, b as InferInternalArgs, c as validateBundledWorkerFile, d as CompletablePositional, f as CompletableSubcommand, g as CompletionOptions, h as CompletionMode, i as GenerateBundledCompletionWorkerResult, l as BundledWorkerOptions, m as CompletionGenerator, n as withCompletionCommand, o as defaultBundledWorkerOutputPath, p as CompletionData, r as GenerateBundledCompletionWorkerOptions, s as generateBundledCompletionWorker, t as WithCompletionOptions, u as CompletableOption, v as ShellType, x as InternalArgsSchema, y as ValueCompletion } from "./with-completion-command-
|
|
1
|
+
import { C as Command, Z as ResolvedFieldMeta, _ as DynamicCompletionResult, b as ArgsSchema, d as ExpandCompletion, g as DynamicCompletionResolver, h as DynamicCompletionContext, m as DynamicCompletionCandidate, p as CompletionDirectiveMask, v as AnyCommand } from "./arg-registry-DdEs3jd0.js";
|
|
2
|
+
import { _ as CompletionResult, a as bundledWorkerShellExtension, b as InferInternalArgs, c as validateBundledWorkerFile, d as CompletablePositional, f as CompletableSubcommand, g as CompletionOptions, h as CompletionMode, i as GenerateBundledCompletionWorkerResult, l as BundledWorkerOptions, m as CompletionGenerator, n as withCompletionCommand, o as defaultBundledWorkerOutputPath, p as CompletionData, r as GenerateBundledCompletionWorkerOptions, s as generateBundledCompletionWorker, t as WithCompletionOptions, u as CompletableOption, v as ShellType, x as InternalArgsSchema, y as ValueCompletion } from "./with-completion-command-Bi7v_Wlq.js";
|
|
3
3
|
//#region ../core/src/completion/schemas.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Schema for the completion command arguments
|
|
@@ -57,6 +57,17 @@ interface CompletionContext {
|
|
|
57
57
|
positionals: CompletablePositional[];
|
|
58
58
|
/** Options already used (to avoid duplicates) */
|
|
59
59
|
usedOptions: Set<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Whether any option has been typed anywhere in this invocation so far,
|
|
62
|
+
* including before a subcommand descent that reset `usedOptions`. Unlike
|
|
63
|
+
* `usedOptions`, this is never cleared.
|
|
64
|
+
*
|
|
65
|
+
* Optional (not just because it defaults to `false`): `CompletionContext`
|
|
66
|
+
* is public API, constructible by hand for `generateCandidates` without
|
|
67
|
+
* going through `parseCompletionContext`, so a new required member would
|
|
68
|
+
* break existing callers. Treat an omitted value the same as `false`.
|
|
69
|
+
*/
|
|
70
|
+
hasAnyOptionBeenUsed?: boolean;
|
|
60
71
|
/** Number of positional arguments already provided */
|
|
61
72
|
providedPositionalCount: number;
|
|
62
73
|
/**
|
|
@@ -83,13 +94,13 @@ interface CompletionContext {
|
|
|
83
94
|
* resolvers attached to global options can be reached from any subcommand.
|
|
84
95
|
* @returns Completion context
|
|
85
96
|
*/
|
|
86
|
-
declare function parseCompletionContext(argv: string[], rootCommand: AnyCommand, globalArgsSchema?: ArgsSchema): CompletionContext;
|
|
97
|
+
export declare function parseCompletionContext(argv: string[], rootCommand: AnyCommand, globalArgsSchema?: ArgsSchema): CompletionContext;
|
|
87
98
|
//#endregion
|
|
88
99
|
//#region ../core/src/completion/dynamic/candidate-generator.d.ts
|
|
89
100
|
/**
|
|
90
101
|
* Completion directive flags (bitwise)
|
|
91
102
|
*/
|
|
92
|
-
declare const CompletionDirective: {
|
|
103
|
+
export declare const CompletionDirective: {
|
|
93
104
|
/** Default completion behavior */
|
|
94
105
|
readonly Default: 0;
|
|
95
106
|
/** Don't add space after completion */
|
|
@@ -152,7 +163,7 @@ interface GenerateCandidatesOptions {
|
|
|
152
163
|
* are stripped here so resolvers and post-processing always see the
|
|
153
164
|
* value portion regardless of whether the caller pre-normalized.
|
|
154
165
|
*/
|
|
155
|
-
declare function generateCandidates(context: CompletionContext, options: GenerateCandidatesOptions): Promise<CandidateResult>;
|
|
166
|
+
export declare function generateCandidates(context: CompletionContext, options: GenerateCandidatesOptions): Promise<CandidateResult>;
|
|
156
167
|
//#endregion
|
|
157
168
|
//#region ../core/src/completion/dynamic/schema.d.ts
|
|
158
169
|
declare const completeArgsSchema: InternalArgsSchema<{
|
|
@@ -172,11 +183,11 @@ type CompleteArgs = InferInternalArgs<typeof completeArgsSchema>;
|
|
|
172
183
|
* reachable at every subcommand level.
|
|
173
184
|
* @returns A command that outputs completion candidates
|
|
174
185
|
*/
|
|
175
|
-
declare function createDynamicCompleteCommand(rootCommand: AnyCommand, _programName?: string, globalArgsSchema?: ArgsSchema): Command<typeof completeArgsSchema, CompleteArgs, any>;
|
|
186
|
+
export declare function createDynamicCompleteCommand(rootCommand: AnyCommand, _programName?: string, globalArgsSchema?: ArgsSchema): Command<typeof completeArgsSchema, CompleteArgs, any>;
|
|
176
187
|
/**
|
|
177
188
|
* Check if a command tree contains the __complete command
|
|
178
189
|
*/
|
|
179
|
-
declare function hasCompleteCommand(command: AnyCommand): boolean;
|
|
190
|
+
export declare function hasCompleteCommand(command: AnyCommand): boolean;
|
|
180
191
|
//#endregion
|
|
181
192
|
//#region ../core/src/completion/dynamic/shell-formatter.d.ts
|
|
182
193
|
/**
|
|
@@ -195,13 +206,13 @@ interface ShellFormatOptions {
|
|
|
195
206
|
*
|
|
196
207
|
* @returns Shell-ready output string (lines separated by newline, last line is :directive)
|
|
197
208
|
*/
|
|
198
|
-
declare function formatForShell(result: CandidateResult, options: ShellFormatOptions): string;
|
|
209
|
+
export declare function formatForShell(result: CandidateResult, options: ShellFormatOptions): string;
|
|
199
210
|
//#endregion
|
|
200
211
|
//#region ../core/src/completion/extractor.d.ts
|
|
201
212
|
/**
|
|
202
213
|
* Extract positional arguments from a command
|
|
203
214
|
*/
|
|
204
|
-
declare function extractPositionals(command: AnyCommand): ResolvedFieldMeta[];
|
|
215
|
+
export declare function extractPositionals(command: AnyCommand): ResolvedFieldMeta[];
|
|
205
216
|
/**
|
|
206
217
|
* Extract completion data from a command tree
|
|
207
218
|
*
|
|
@@ -210,7 +221,7 @@ declare function extractPositionals(command: AnyCommand): ResolvedFieldMeta[];
|
|
|
210
221
|
* @param globalArgsSchema - Optional global args schema. When provided, global options
|
|
211
222
|
* are derived from this schema instead of the root command's options.
|
|
212
223
|
*/
|
|
213
|
-
declare function extractCompletionData(command: AnyCommand, programName: string, globalArgsSchema?: ArgsSchema, validateOnly?: boolean): CompletionData;
|
|
224
|
+
export declare function extractCompletionData(command: AnyCommand, programName: string, globalArgsSchema?: ArgsSchema, validateOnly?: boolean): CompletionData;
|
|
214
225
|
//#endregion
|
|
215
226
|
//#region ../core/src/completion/value-completion-resolver.d.ts
|
|
216
227
|
/**
|
|
@@ -262,7 +273,7 @@ interface ValueCompletionField {
|
|
|
262
273
|
* Outside `custom`: explicit `type` (file/directory/none) > auto-detected
|
|
263
274
|
* enum values from the schema.
|
|
264
275
|
*/
|
|
265
|
-
declare function resolveValueCompletion(field: ValueCompletionField): ValueCompletion | PendingExpandValueCompletion | undefined;
|
|
276
|
+
export declare function resolveValueCompletion(field: ValueCompletionField): ValueCompletion | PendingExpandValueCompletion | undefined;
|
|
266
277
|
//#endregion
|
|
267
278
|
//#region ../core/src/completion/detect-shell.d.ts
|
|
268
279
|
/**
|
|
@@ -272,17 +283,17 @@ declare function resolveValueCompletion(field: ValueCompletionField): ValueCompl
|
|
|
272
283
|
* shell for the runMain background-refresh hook without statically pulling
|
|
273
284
|
* in the bash/zsh/fish generators.
|
|
274
285
|
*/
|
|
275
|
-
declare function detectShell(): ShellType | null;
|
|
286
|
+
export declare function detectShell(): ShellType | null;
|
|
276
287
|
//#endregion
|
|
277
288
|
//#region ../core/src/completion/index.d.ts
|
|
278
289
|
/**
|
|
279
290
|
* Generate completion script for the specified shell
|
|
280
291
|
*/
|
|
281
|
-
declare function generateCompletion(command: AnyCommand, options: CompletionOptions): CompletionResult;
|
|
292
|
+
export declare function generateCompletion(command: AnyCommand, options: CompletionOptions): CompletionResult;
|
|
282
293
|
/**
|
|
283
294
|
* Get the list of supported shells
|
|
284
295
|
*/
|
|
285
|
-
declare function getSupportedShells(): ShellType[];
|
|
296
|
+
export declare function getSupportedShells(): ShellType[];
|
|
286
297
|
/**
|
|
287
298
|
* Create a completion subcommand for your CLI
|
|
288
299
|
*
|
|
@@ -298,7 +309,7 @@ declare function getSupportedShells(): ShellType[];
|
|
|
298
309
|
* });
|
|
299
310
|
* ```
|
|
300
311
|
*/
|
|
301
|
-
declare function createCompletionCommand(rootCommand: AnyCommand, programName?: string, globalArgsSchema?: ArgsSchema, extra?: {
|
|
312
|
+
export declare function createCompletionCommand(rootCommand: AnyCommand, programName?: string, globalArgsSchema?: ArgsSchema, extra?: {
|
|
302
313
|
cacheDir?: string;
|
|
303
314
|
programVersion?: string;
|
|
304
315
|
bundledWorker?: BundledWorkerOptions;
|
|
@@ -308,15 +319,15 @@ declare function createCompletionCommand(rootCommand: AnyCommand, programName?:
|
|
|
308
319
|
* the same stat-compare + atomic rewrite as the rc loader, but in a
|
|
309
320
|
* detached child process so it's invisible to the user.
|
|
310
321
|
*/
|
|
311
|
-
declare function createRefreshCompletionCommand(rootCommand: AnyCommand, programName: string, extra?: {
|
|
322
|
+
export declare function createRefreshCompletionCommand(rootCommand: AnyCommand, programName: string, extra?: {
|
|
312
323
|
cacheDir?: string;
|
|
313
324
|
programVersion?: string;
|
|
314
325
|
globalArgsSchema?: ArgsSchema;
|
|
315
326
|
bundledWorker?: BundledWorkerOptions;
|
|
316
327
|
}): Command<typeof refreshArgsSchema, RefreshArgs, any>;
|
|
317
|
-
declare function createCompletionWorkerPathCommand(programName: string, extra?: {
|
|
328
|
+
export declare function createCompletionWorkerPathCommand(programName: string, extra?: {
|
|
318
329
|
binPath?: string;
|
|
319
330
|
bundledWorker?: BundledWorkerOptions;
|
|
320
331
|
}): Command<typeof workerPathArgsSchema, WorkerPathArgs, any>;
|
|
321
332
|
//#endregion
|
|
322
|
-
export { type BundledWorkerOptions, type CandidateResult, type CompletableOption, type CompletableSubcommand, type CompletionCandidate, type CompletionContext, type CompletionData,
|
|
333
|
+
export { type BundledWorkerOptions, type CandidateResult, type CompletableOption, type CompletableSubcommand, type CompletionCandidate, type CompletionContext, type CompletionData, type CompletionDirectiveMask, type CompletionGenerator, type CompletionMode, type CompletionOptions, type CompletionResult, type CompletionType, type DynamicCompletionCandidate, type DynamicCompletionContext, type DynamicCompletionResolver, type DynamicCompletionResult, type GenerateBundledCompletionWorkerOptions, type GenerateBundledCompletionWorkerResult, type ShellFormatOptions, type ShellType, type ValueCompletionField, type WithCompletionOptions, bundledWorkerShellExtension, defaultBundledWorkerOutputPath, generateBundledCompletionWorker, validateBundledWorkerFile, withCompletionCommand };
|
package/dist/completion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./register-
|
|
1
|
+
import"./register-D0mDOOyc.js";import{s as e,t}from"./with-completion-command-CZ9qcezN.js";import{a as n,i as r,n as i,o as a,r as o,s,t as c}from"./dynamic-BK6Tq_FR.js";import{a as l,c as u,d,i as f,l as p,n as m,o as h,r as g,s as _,t as v,u as y}from"./completion-DwBjO-3Q.js";export{r as CompletionDirective,h as bundledWorkerShellExtension,v as createCompletionCommand,m as createCompletionWorkerPathCommand,c as createDynamicCompleteCommand,g as createRefreshCompletionCommand,_ as defaultBundledWorkerOutputPath,e as detectShell,y as extractCompletionData,d as extractPositionals,o as formatForShell,u as generateBundledCompletionWorker,n as generateCandidates,f as generateCompletion,l as getSupportedShells,i as hasCompleteCommand,a as parseCompletionContext,s as resolveValueCompletion,p as validateBundledWorkerFile,t as withCompletionCommand};
|
package/dist/docs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as Example, W as SubCommandValue, X as ExtractedFields, Z as ResolvedFieldMeta, b as ArgsSchema, nt as SchemaLike, v as AnyCommand } from "./arg-registry-
|
|
1
|
+
import { T as Example, W as SubCommandValue, X as ExtractedFields, Z as ResolvedFieldMeta, b as ArgsSchema, nt as SchemaLike, v as AnyCommand } from "./arg-registry-DdEs3jd0.js";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
//#region ../core/src/executor/subcommand-router.d.ts
|
|
4
4
|
/**
|
|
@@ -7,7 +7,7 @@ import * as fs from "node:fs";
|
|
|
7
7
|
* @param cmd - The command or lazy loader function
|
|
8
8
|
* @returns The resolved command
|
|
9
9
|
*/
|
|
10
|
-
declare function resolveLazyCommand(cmd: SubCommandValue): Promise<AnyCommand>;
|
|
10
|
+
export declare function resolveLazyCommand(cmd: SubCommandValue): Promise<AnyCommand>;
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region ../core/src/docs/option-rows.d.ts
|
|
13
13
|
/**
|
|
@@ -52,7 +52,7 @@ type ArgsTableOptions = {
|
|
|
52
52
|
* @param options - Rendering options
|
|
53
53
|
* @returns Rendered markdown table string
|
|
54
54
|
*/
|
|
55
|
-
declare function renderArgsTable(args: ArgsShape, options?: ArgsTableOptions): string;
|
|
55
|
+
export declare function renderArgsTable(args: ArgsShape, options?: ArgsTableOptions): string;
|
|
56
56
|
//#endregion
|
|
57
57
|
//#region ../core/src/docs/types.d.ts
|
|
58
58
|
/** Heading level for markdown headings (1-6) */
|
|
@@ -479,17 +479,17 @@ type FormatterFunction = (content: string) => string | Promise<string>;
|
|
|
479
479
|
/**
|
|
480
480
|
* Environment variable name for update mode
|
|
481
481
|
*/
|
|
482
|
-
declare const UPDATE_GOLDEN_ENV = "POLITTY_DOCS_UPDATE";
|
|
482
|
+
export declare const UPDATE_GOLDEN_ENV = "POLITTY_DOCS_UPDATE";
|
|
483
483
|
/**
|
|
484
484
|
* Environment variable name for doctor mode.
|
|
485
485
|
* When enabled alone, detects and reports missing section markers (read-only).
|
|
486
486
|
* When combined with POLITTY_DOCS_UPDATE=true, auto-inserts missing markers.
|
|
487
487
|
*/
|
|
488
|
-
declare const DOCTOR_ENV = "POLITTY_DOCS_DOCTOR";
|
|
488
|
+
export declare const DOCTOR_ENV = "POLITTY_DOCS_DOCTOR";
|
|
489
489
|
/**
|
|
490
490
|
* All section types in rendering order
|
|
491
491
|
*/
|
|
492
|
-
declare const SECTION_TYPES: readonly ["heading", "description", "usage", "arguments", "options", "global-options-link", "subcommands", "examples", "notes"];
|
|
492
|
+
export declare const SECTION_TYPES: readonly ["heading", "description", "usage", "arguments", "options", "global-options-link", "subcommands", "examples", "notes"];
|
|
493
493
|
/**
|
|
494
494
|
* Section types for command documentation markers
|
|
495
495
|
*/
|
|
@@ -498,67 +498,67 @@ type SectionType = (typeof SECTION_TYPES)[number];
|
|
|
498
498
|
* Marker prefix for command section markers in generated documentation
|
|
499
499
|
* Format: <!-- politty:command:<scope>:<type>:start --> ... <!-- politty:command:<scope>:<type>:end -->
|
|
500
500
|
*/
|
|
501
|
-
declare const SECTION_MARKER_PREFIX = "politty:command";
|
|
501
|
+
export declare const SECTION_MARKER_PREFIX = "politty:command";
|
|
502
502
|
/**
|
|
503
503
|
* Generate start marker for a command section
|
|
504
504
|
*/
|
|
505
|
-
declare function sectionStartMarker(type: SectionType, scope: string): string;
|
|
505
|
+
export declare function sectionStartMarker(type: SectionType, scope: string): string;
|
|
506
506
|
/**
|
|
507
507
|
* Generate end marker for a command section
|
|
508
508
|
*/
|
|
509
|
-
declare function sectionEndMarker(type: SectionType, scope: string): string;
|
|
509
|
+
export declare function sectionEndMarker(type: SectionType, scope: string): string;
|
|
510
510
|
/**
|
|
511
511
|
* Marker prefix for global options sections in generated documentation
|
|
512
512
|
* Format: <!-- politty:global-options:start --> ... <!-- politty:global-options:end -->
|
|
513
513
|
*/
|
|
514
|
-
declare const GLOBAL_OPTIONS_MARKER_PREFIX = "politty:global-options";
|
|
514
|
+
export declare const GLOBAL_OPTIONS_MARKER_PREFIX = "politty:global-options";
|
|
515
515
|
/**
|
|
516
516
|
* Generate start marker for a global options section
|
|
517
517
|
*/
|
|
518
|
-
declare function globalOptionsStartMarker(): string;
|
|
518
|
+
export declare function globalOptionsStartMarker(): string;
|
|
519
519
|
/**
|
|
520
520
|
* Generate end marker for a global options section
|
|
521
521
|
*/
|
|
522
|
-
declare function globalOptionsEndMarker(): string;
|
|
522
|
+
export declare function globalOptionsEndMarker(): string;
|
|
523
523
|
/**
|
|
524
524
|
* Marker prefix for root header sections in generated documentation
|
|
525
525
|
*/
|
|
526
|
-
declare const ROOT_HEADER_MARKER_PREFIX = "politty:root-header";
|
|
527
|
-
declare function rootHeaderStartMarker(): string;
|
|
528
|
-
declare function rootHeaderEndMarker(): string;
|
|
526
|
+
export declare const ROOT_HEADER_MARKER_PREFIX = "politty:root-header";
|
|
527
|
+
export declare function rootHeaderStartMarker(): string;
|
|
528
|
+
export declare function rootHeaderEndMarker(): string;
|
|
529
529
|
/**
|
|
530
530
|
* Marker prefix for root footer sections in generated documentation
|
|
531
531
|
*/
|
|
532
|
-
declare const ROOT_FOOTER_MARKER_PREFIX = "politty:root-footer";
|
|
533
|
-
declare function rootFooterStartMarker(): string;
|
|
534
|
-
declare function rootFooterEndMarker(): string;
|
|
532
|
+
export declare const ROOT_FOOTER_MARKER_PREFIX = "politty:root-footer";
|
|
533
|
+
export declare function rootFooterStartMarker(): string;
|
|
534
|
+
export declare function rootFooterEndMarker(): string;
|
|
535
535
|
/**
|
|
536
536
|
* Marker prefix for index sections in generated documentation
|
|
537
537
|
* Format: <!-- politty:index:<scope>:start --> ... <!-- politty:index:<scope>:end -->
|
|
538
538
|
*/
|
|
539
|
-
declare const INDEX_MARKER_PREFIX = "politty:index";
|
|
539
|
+
export declare const INDEX_MARKER_PREFIX = "politty:index";
|
|
540
540
|
/**
|
|
541
541
|
* Generate start marker for an index section
|
|
542
542
|
*/
|
|
543
|
-
declare function indexStartMarker(scope: string): string;
|
|
543
|
+
export declare function indexStartMarker(scope: string): string;
|
|
544
544
|
/**
|
|
545
545
|
* Generate end marker for an index section
|
|
546
546
|
*/
|
|
547
|
-
declare function indexEndMarker(scope: string): string;
|
|
547
|
+
export declare function indexEndMarker(scope: string): string;
|
|
548
548
|
//#endregion
|
|
549
549
|
//#region ../core/src/docs/default-renderers.d.ts
|
|
550
550
|
/**
|
|
551
551
|
* Render usage line
|
|
552
552
|
*/
|
|
553
|
-
declare function renderUsage(info: CommandInfo): string;
|
|
553
|
+
export declare function renderUsage(info: CommandInfo): string;
|
|
554
554
|
/**
|
|
555
555
|
* Render arguments as table
|
|
556
556
|
*/
|
|
557
|
-
declare function renderArgumentsTable(info: CommandInfo): string;
|
|
557
|
+
export declare function renderArgumentsTable(info: CommandInfo): string;
|
|
558
558
|
/**
|
|
559
559
|
* Render arguments as list
|
|
560
560
|
*/
|
|
561
|
-
declare function renderArgumentsList(info: CommandInfo): string;
|
|
561
|
+
export declare function renderArgumentsList(info: CommandInfo): string;
|
|
562
562
|
/**
|
|
563
563
|
* Render options as markdown table
|
|
564
564
|
*
|
|
@@ -573,7 +573,7 @@ declare function renderArgumentsList(info: CommandInfo): string;
|
|
|
573
573
|
* | `--dry-run` | `-d` | Dry run mode | No | `false` | - |
|
|
574
574
|
* | `--port <PORT>` | - | Server port | Yes | - | `PORT`, `SERVER_PORT` |
|
|
575
575
|
*/
|
|
576
|
-
declare function renderOptionsTable(info: CommandInfo): string;
|
|
576
|
+
export declare function renderOptionsTable(info: CommandInfo): string;
|
|
577
577
|
/**
|
|
578
578
|
* Render options as markdown list
|
|
579
579
|
*
|
|
@@ -585,31 +585,31 @@ declare function renderOptionsTable(info: CommandInfo): string;
|
|
|
585
585
|
* - `-d`, `--dry-run` - Dry run mode (default: false)
|
|
586
586
|
* - `--port <PORT>` - Server port (required) [env: PORT, SERVER_PORT]
|
|
587
587
|
*/
|
|
588
|
-
declare function renderOptionsList(info: CommandInfo): string;
|
|
588
|
+
export declare function renderOptionsList(info: CommandInfo): string;
|
|
589
589
|
/**
|
|
590
590
|
* Render subcommands as table
|
|
591
591
|
*/
|
|
592
|
-
declare function renderSubcommandsTable(info: CommandInfo, generateAnchors?: boolean): string;
|
|
592
|
+
export declare function renderSubcommandsTable(info: CommandInfo, generateAnchors?: boolean): string;
|
|
593
593
|
/**
|
|
594
594
|
* Render options from array as table
|
|
595
595
|
*/
|
|
596
|
-
declare function renderOptionsTableFromArray(options: ResolvedFieldMeta[]): string;
|
|
596
|
+
export declare function renderOptionsTableFromArray(options: ResolvedFieldMeta[]): string;
|
|
597
597
|
/**
|
|
598
598
|
* Render options from array as list
|
|
599
599
|
*/
|
|
600
|
-
declare function renderOptionsListFromArray(options: ResolvedFieldMeta[]): string;
|
|
600
|
+
export declare function renderOptionsListFromArray(options: ResolvedFieldMeta[]): string;
|
|
601
601
|
/**
|
|
602
602
|
* Render arguments from array as table
|
|
603
603
|
*/
|
|
604
|
-
declare function renderArgumentsTableFromArray(args: ResolvedFieldMeta[]): string;
|
|
604
|
+
export declare function renderArgumentsTableFromArray(args: ResolvedFieldMeta[]): string;
|
|
605
605
|
/**
|
|
606
606
|
* Render arguments from array as list
|
|
607
607
|
*/
|
|
608
|
-
declare function renderArgumentsListFromArray(args: ResolvedFieldMeta[]): string;
|
|
608
|
+
export declare function renderArgumentsListFromArray(args: ResolvedFieldMeta[]): string;
|
|
609
609
|
/**
|
|
610
610
|
* Render subcommands from array as table
|
|
611
611
|
*/
|
|
612
|
-
declare function renderSubcommandsTableFromArray(subcommands: SubCommandInfo[], info: CommandInfo, generateAnchors?: boolean): string;
|
|
612
|
+
export declare function renderSubcommandsTableFromArray(subcommands: SubCommandInfo[], info: CommandInfo, generateAnchors?: boolean): string;
|
|
613
613
|
/**
|
|
614
614
|
* Render examples as markdown
|
|
615
615
|
*
|
|
@@ -625,12 +625,12 @@ declare function renderSubcommandsTableFromArray(subcommands: SubCommandInfo[],
|
|
|
625
625
|
* Hello, World!
|
|
626
626
|
* ```
|
|
627
627
|
*/
|
|
628
|
-
declare function renderExamplesDefault(examples: Example[], results?: ExampleExecutionResult[], opts?: ExamplesRenderOptions): string;
|
|
629
|
-
declare function createCommandRenderer(options?: DefaultRendererOptions): RenderFunction;
|
|
628
|
+
export declare function renderExamplesDefault(examples: Example[], results?: ExampleExecutionResult[], opts?: ExamplesRenderOptions): string;
|
|
629
|
+
export declare function createCommandRenderer(options?: DefaultRendererOptions): RenderFunction;
|
|
630
630
|
/**
|
|
631
631
|
* Default renderers presets
|
|
632
632
|
*/
|
|
633
|
-
declare const defaultRenderers: {
|
|
633
|
+
export declare const defaultRenderers: {
|
|
634
634
|
/** Standard command documentation */
|
|
635
635
|
command: (options?: DefaultRendererOptions) => RenderFunction;
|
|
636
636
|
/** Table style options (default) */
|
|
@@ -654,15 +654,15 @@ interface CompareResult {
|
|
|
654
654
|
/**
|
|
655
655
|
* Compare generated content with existing file
|
|
656
656
|
*/
|
|
657
|
-
declare function compareWithExisting(generatedContent: string, filePath: string): CompareResult;
|
|
657
|
+
export declare function compareWithExisting(generatedContent: string, filePath: string): CompareResult;
|
|
658
658
|
/**
|
|
659
659
|
* Format diff between two strings in unified diff format
|
|
660
660
|
*/
|
|
661
|
-
declare function formatDiff(expected: string, actual: string): string;
|
|
661
|
+
export declare function formatDiff(expected: string, actual: string): string;
|
|
662
662
|
/**
|
|
663
663
|
* Write content to file, creating directories if needed
|
|
664
664
|
*/
|
|
665
|
-
declare function writeFile(filePath: string, content: string): void;
|
|
665
|
+
export declare function writeFile(filePath: string, content: string): void;
|
|
666
666
|
/**
|
|
667
667
|
* Minimal fs interface for deleteFile
|
|
668
668
|
*/
|
|
@@ -675,12 +675,12 @@ interface DeleteFileFs {
|
|
|
675
675
|
/**
|
|
676
676
|
* Build CommandInfo from a command
|
|
677
677
|
*/
|
|
678
|
-
declare function buildCommandInfo(command: AnyCommand, rootName: string, commandPath?: string[]): Promise<CommandInfo>;
|
|
678
|
+
export declare function buildCommandInfo(command: AnyCommand, rootName: string, commandPath?: string[]): Promise<CommandInfo>;
|
|
679
679
|
/**
|
|
680
680
|
* Collect all commands with their paths
|
|
681
681
|
* Returns a map of command path -> CommandInfo
|
|
682
682
|
*/
|
|
683
|
-
declare function collectAllCommands(command: AnyCommand, rootName?: string): Promise<Map<string, CommandInfo>>;
|
|
683
|
+
export declare function collectAllCommands(command: AnyCommand, rootName?: string): Promise<Map<string, CommandInfo>>;
|
|
684
684
|
//#endregion
|
|
685
685
|
//#region ../core/src/docs/example-executor.d.ts
|
|
686
686
|
/**
|
|
@@ -692,18 +692,18 @@ declare function collectAllCommands(command: AnyCommand, rootName?: string): Pro
|
|
|
692
692
|
* @param commandPath - Command path for subcommands (e.g., ["config", "get"])
|
|
693
693
|
* @returns Array of execution results with captured stdout/stderr
|
|
694
694
|
*/
|
|
695
|
-
declare function executeExamples(examples: Example[], config: ExampleCommandConfig, rootCommand: AnyCommand, commandPath?: string[]): Promise<ExampleExecutionResult[]>;
|
|
695
|
+
export declare function executeExamples(examples: Example[], config: ExampleCommandConfig, rootCommand: AnyCommand, commandPath?: string[]): Promise<ExampleExecutionResult[]>;
|
|
696
696
|
//#endregion
|
|
697
697
|
//#region ../core/src/docs/golden-test.d.ts
|
|
698
698
|
/**
|
|
699
699
|
* Generate documentation from command definition
|
|
700
700
|
*/
|
|
701
|
-
declare function generateDoc(config: GenerateDocConfig): Promise<GenerateDocResult>;
|
|
701
|
+
export declare function generateDoc(config: GenerateDocConfig): Promise<GenerateDocResult>;
|
|
702
702
|
/**
|
|
703
703
|
* Assert that documentation matches golden files
|
|
704
704
|
* Throws an error if there are differences and update mode is not enabled
|
|
705
705
|
*/
|
|
706
|
-
declare function assertDocMatch(config: GenerateDocConfig): Promise<void>;
|
|
706
|
+
export declare function assertDocMatch(config: GenerateDocConfig): Promise<void>;
|
|
707
707
|
/**
|
|
708
708
|
* Initialize documentation files by deleting them
|
|
709
709
|
* Only deletes when update mode is enabled (POLITTY_DOCS_UPDATE=true)
|
|
@@ -711,7 +711,7 @@ declare function assertDocMatch(config: GenerateDocConfig): Promise<void>;
|
|
|
711
711
|
* @param config - Config containing files to initialize, or a single file path
|
|
712
712
|
* @param fileSystem - Optional fs implementation (useful when fs is mocked)
|
|
713
713
|
*/
|
|
714
|
-
declare function initDocFile(config: Pick<GenerateDocConfig, "files" | "templates" | "rootDoc"> | string, fileSystem?: DeleteFileFs): void;
|
|
714
|
+
export declare function initDocFile(config: Pick<GenerateDocConfig, "files" | "templates" | "rootDoc"> | string, fileSystem?: DeleteFileFs): void;
|
|
715
715
|
//#endregion
|
|
716
716
|
//#region ../core/src/docs/render-index.d.ts
|
|
717
717
|
/**
|
|
@@ -765,6 +765,6 @@ type CommandCategory = {
|
|
|
765
765
|
* @param options - Rendering options
|
|
766
766
|
* @returns Rendered markdown string
|
|
767
767
|
*/
|
|
768
|
-
declare function renderCommandIndex(command: AnyCommand, categories: CommandCategory[], options?: CommandIndexOptions): Promise<string>;
|
|
768
|
+
export declare function renderCommandIndex(command: AnyCommand, categories: CommandCategory[], options?: CommandIndexOptions): Promise<string>;
|
|
769
769
|
//#endregion
|
|
770
|
-
export {
|
|
770
|
+
export type { ArgsShape, ArgsTableOptions, ArgumentsRenderContext, ArgumentsRenderFunction, CommandCategory, CommandIndexOptions, CommandInfo, DefaultRendererOptions, DeleteFileFs, ExampleCommandConfig, ExampleConfig, ExampleExecutionResult, ExamplesRenderContext, ExamplesRenderFunction, ExamplesRenderOptions, FileConfig, FileMapping, FormatterFunction, GenerateDocConfig, GenerateDocResult, HeadingLevel, OptionsRenderContext, OptionsRenderFunction, PathConfig, RenderContentOptions, RenderFunction, RootCommandInfo, RootDocConfig, SectionRenderFunction, SectionType, SimpleRenderContext, SimpleRenderFunction, SubCommandInfo, SubcommandsRenderContext, SubcommandsRenderFunction, SubcommandsRenderOptions };
|
package/dist/docs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{o as e}from"./field-meta-D7G8a7IG.js";import"./register-D0mDOOyc.js";import{n as t,t as n}from"./schema-extractor-QpSHJvwI.js";import{t as r}from"./log-collector-DICKib75.js";import{r as i}from"./subcommand-router-D8GTMXYL.js";import*as a from"node:fs";import*as o from"node:path";import s from"node:path";import{isDeepStrictEqual as c}from"node:util";const l=[`option`,`alias`,`description`,`required`,`default`];function u(e){return`(↔ \`--${e.cliName}\`)`}function d(e){return e.placeholder??e.cliName.toUpperCase().replace(/-/g,`_`)}function f(e){let t=e.type===`boolean`?`--${e.cliName}`:`--${e.cliName} <${d(e)}>`,n=[];if(e.alias)for(let t of e.alias)n.push(t.length===1?`-${t}`:`--${t}`);let r=e.type===`boolean`&&!!e.negationDisplay,i=r&&!e.negationDescription?`--${e.negationDisplay}`:void 0,a=r&&e.negationDescription?{flag:`--${e.negationDisplay}`,description:e.negationDescription,relationMarker:u(e),required:e.required}:void 0;return{longFlag:t,aliases:n,inlineNegation:i,description:e.description,required:e.required,hasDefault:e.defaultValue!==void 0,defaultValue:e.defaultValue,env:e.env,negationRow:a}}function p(e){return e.map(f)}function m(e){return e.replace(/\r?\n/g,`<br>`)}function h(e){return m(e.replace(/\|/g,`\\|`))}function g(e){return`\`${e}\``}function _(e){return e.hasDefault?`\`${JSON.stringify(e.defaultValue)}\``:`-`}function v(e){return e?Array.isArray(e)?e.map(e=>`\`${e}\``).join(`, `):`\`${e}\``:`-`}function y(e){return e?` [env: ${(Array.isArray(e)?e:[e]).join(`, `)}]`:``}const b={option:{header:`Option`,separator:`--------`},alias:{header:`Alias`,separator:`-------`},description:{header:`Description`,separator:`-------------`},required:{header:`Required`,separator:`----------`},default:{header:`Default`,separator:`---------`},env:{header:`Env`,separator:`-----`}};function x(e,t){switch(t){case`option`:{let t=g(e.longFlag);return e.inlineNegation?`${t} / ${g(e.inlineNegation)}`:t}case`alias`:return e.aliases.length>0?e.aliases.map(g).join(`, `):`-`;case`description`:return h(e.description??``);case`required`:return e.required?`Yes`:`No`;case`default`:return _(e);case`env`:return v(e.env)}}function S(e,t){switch(t){case`option`:return g(e.flag);case`description`:return`${h(e.description)} ${e.relationMarker}`;case`required`:return e.required?`Yes`:`No`;case`alias`:case`default`:case`env`:return`-`}}function C(e,t){if(e.length===0)return``;let n=t??(e.some(e=>e.env)?[...l,`env`]:l),r=[];r.push(`| ${n.map(e=>b[e].header).join(` | `)} |`),r.push(`|${n.map(e=>b[e].separator).join(`|`)}|`);for(let t of e)r.push(`| ${n.map(e=>x(t,e)).join(` | `)} |`),t.negationRow&&r.push(`| ${n.map(e=>S(t.negationRow,e)).join(` | `)} |`);return r.join(`
|
|
2
2
|
`)}function w(e){if(e.length===0)return``;let t=[];for(let n of e){let e=n.aliases.filter(e=>!e.startsWith(`--`)),r=n.aliases.filter(e=>e.startsWith(`--`)),i=[...e,n.longFlag,...r].map(g).join(`, `);n.inlineNegation&&(i+=` / ${g(n.inlineNegation)}`);let a=n.description?` - ${m(n.description)}`:``,o=n.required?` (required)`:``,s=n.hasDefault?` (default: ${JSON.stringify(n.defaultValue)})`:``,c=y(n.env);t.push(`- ${i}${a}${o}${s}${c}`),n.negationRow&&t.push(`- ${g(n.negationRow.flag)} - ${m(n.negationRow.description)} ${n.negationRow.relationMarker}`)}return t.join(`
|
|
3
|
-
`)}const T=`POLITTY_DOCS_UPDATE`,E=`POLITTY_DOCS_DOCTOR`,D=[`heading`,`description`,`usage`,`arguments`,`options`,`global-options-link`,`subcommands`,`examples`,`notes`],O=`politty:command`;function k(e,t){return`<!-- ${O}:${t}:${e}:start -->`}function A(e,t){return`<!-- ${O}:${t}:${e}:end -->`}const j=`politty:global-options`;function M(){return`<!-- ${j}:start -->`}function N(){return`<!-- ${j}:end -->`}const P=`politty:root-header`;function ee(){return`<!-- ${P}:start -->`}function te(){return`<!-- ${P}:end -->`}const F=`politty:root-footer`;function ne(){return`<!-- ${F}:start -->`}function re(){return`<!-- ${F}:end -->`}const I=`politty:index`;function L(e){return`<!-- ${I}:${e}:start -->`}function ie(e){return`<!-- ${I}:${e}:end -->`}function R(e){return m(e.replace(/\|/g,`\\|`))}function z(e){let t=[e.fullCommandPath];e.options.length>0&&t.push(`[options]`),e.subCommands.length>0&&(e.command.run?t.push(`[command]`):t.push(`<command>`));for(let n of e.positionalArgs)n.required?t.push(`<${n.name}>`):t.push(`[${n.name}]`);return t.join(` `)}function B(e){if(e.positionalArgs.length===0)return``;let t=[];t.push(`| Argument | Description | Required |`),t.push(`|----------|-------------|----------|`);for(let n of e.positionalArgs){let e=R(n.description??``),r=n.required?`Yes`:`No`;t.push(`| \`${n.name}\` | ${e} | ${r} |`)}return t.join(`
|
|
3
|
+
`)}const T=`POLITTY_DOCS_UPDATE`,E=`POLITTY_DOCS_DOCTOR`,D=[`heading`,`description`,`usage`,`arguments`,`options`,`global-options-link`,`subcommands`,`examples`,`notes`],O=`politty:command`;function k(e,t){return`<!-- ${O}:${t}:${e}:start -->`}function A(e,t){return`<!-- ${O}:${t}:${e}:end -->`}const j=`politty:global-options`;function M(){return`<!-- ${j}:start -->`}function N(){return`<!-- ${j}:end -->`}const P=`politty:root-header`;function ee(){return`<!-- ${P}:start -->`}function te(){return`<!-- ${P}:end -->`}const F=`politty:root-footer`;function ne(){return`<!-- ${F}:start -->`}function re(){return`<!-- ${F}:end -->`}const I=`politty:index`;function L(e){return`<!-- ${I}:${e}:start -->`}function ie(e){return`<!-- ${I}:${e}:end -->`}function R(e){return m(e.replace(/\|/g,`\\|`))}function z(e){let t=[e.fullCommandPath];e.options.length>0&&t.push(`[options]`),e.subCommands.length>0&&(e.command.run||e.command.defaultSubCommand?t.push(`[command]`):t.push(`<command>`));for(let n of e.positionalArgs)n.required?t.push(`<${n.name}>`):t.push(`[${n.name}]`);return t.join(` `)}function B(e){if(e.positionalArgs.length===0)return``;let t=[];t.push(`| Argument | Description | Required |`),t.push(`|----------|-------------|----------|`);for(let n of e.positionalArgs){let e=R(n.description??``),r=n.required?`Yes`:`No`;t.push(`| \`${n.name}\` | ${e} | ${r} |`)}return t.join(`
|
|
4
4
|
`)}function V(e){if(e.positionalArgs.length===0)return``;let t=[];for(let n of e.positionalArgs){let e=n.required?`(required)`:`(optional)`,r=n.description?` - ${m(n.description)}`:``;t.push(`- \`${n.name}\`${r} ${e}`)}return t.join(`
|
|
5
5
|
`)}function ae(e){return C(p(e.options))}function oe(e){return w(p(e.options))}function se(e){return e.join(`-`).toLowerCase()}function ce(e,t){let n=e.replace(/\\/g,`/`),r=t.replace(/\\/g,`/`);return s.posix.relative(s.posix.dirname(n),r)}function le(e,t=!0){return me(e.subCommands,e,t)}function H(e){return C(p(e))}function ue(e,t=`table`){let n=e.unionOptions??[];if(n.length===0)return``;let r=[],i=new Set;for(let e of n)for(let t of e.fields)i.add(t.name);let a=new Set;for(let e of i)n.every(t=>t.fields.some(t=>t.name===e))&&a.add(e);let o=e.fields.filter(e=>a.has(e.name)&&!e.positional);o.length>0&&r.push(t===`table`?H(o):U(o)),r.push(`> One of the following option groups is required:`);for(let e=0;e<n.length;e++){let i=n[e];if(!i)continue;let o=i.fields.filter(e=>!a.has(e.name)&&!e.positional),s=i.description??`Variant ${e+1}`;if(o.length===0){r.push(`**${s}:**\n\n_no options_`);continue}let c=t===`table`?H(o):U(o);r.push(`**${s}:**\n\n${c}`)}return r.join(`
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ import{a as e}from"./field-meta-COGya7xp.js";import"./register-C1WbbeYH.js";impo
|
|
|
18
18
|
`}}const ve={command:e=>W(e),tableStyle:W({optionStyle:`table`}),listStyle:W({optionStyle:`list`})};function ye(e,t){let n=o.resolve(t);if(!a.existsSync(n))return{match:!1,fileExists:!1};let r=a.readFileSync(n,`utf-8`);return e===r?{match:!0,fileExists:!0}:{match:!1,diff:G(r,e),fileExists:!0}}function G(e,t){let n=e.split(`
|
|
19
19
|
`),r=t.split(`
|
|
20
20
|
`),i=[];i.push(`--- existing`),i.push(`+++ generated`),i.push(``);let a=Math.max(n.length,r.length),o=!1,s=0,c=[],l=()=>{c.length>0&&(i.push(`@@ -${s+1},${c.length} @@`),i.push(...c),c.length=0),o=!1};for(let e=0;e<a;e++){let t=n[e],i=r[e];if(t===i){if(o){c.push(` ${t??``}`);let e=c.findIndex((e,t)=>(e.startsWith(`-`)||e.startsWith(`+`))&&c.slice(t+1).every(e=>e.startsWith(` `)));e!==-1&&c.length-e>3&&l()}}else{if(!o){o=!0,s=e;let t=Math.max(0,e-3);for(let r=t;r<e;r++)c.push(` ${n[r]??``}`)}t!==void 0&&(i===void 0||t!==i)&&c.push(`-${t}`),i!==void 0&&(t===void 0||t!==i)&&c.push(`+${i}`)}}return l(),i.join(`
|
|
21
|
-
`)}function K(e,t){let n=o.resolve(e),r=o.dirname(n);a.existsSync(r)||a.mkdirSync(r,{recursive:!0}),a.writeFileSync(n,t,`utf-8`)}function be(e){let t=o.resolve(e);return a.existsSync(t)?a.readFileSync(t,`utf-8`):null}function xe(e,t=a){let n=o.resolve(e);t.existsSync(n)&&t.unlinkSync(n)}async function Se(e,n,r=[]){let a=t(e),o=a?.fields.filter(e=>e.positional)??[],s=a?.fields.filter(e=>!e.positional)??[],c=[];if(e.subCommands)for(let[t,n]of Object.entries(e.subCommands)){let e=await i(n),a=[...r,t];c.push({name:t,description:e.description,aliases:e.aliases,fullPath:a})}return{name:e.name??``,description:e.description,aliases:e.aliases,fullCommandPath:r.length>0?`${n} ${r.join(` `)}`:n,commandPath:r.join(` `),depth:r.length+1,positionalArgs:o,options:s,subCommands:c,extracted:a,command:e,notes:e.notes,examples:e.examples}}async function Ce(e,t){let n=t??e.name??`command`,r=new Map;async function a(e,t){let o=await Se(e,n,t),s=t.join(` `);if(r.set(s,o),e.subCommands)for(let[n,r]of Object.entries(e.subCommands))await a(await i(r),[...t,n])}return await a(e,[]),r}async function we(e,t,n,r=[]){let i=[];t.mock&&await t.mock();try{for(let t of e){let e=await Te(t,n,r);i.push(e)}}finally{t.cleanup&&await t.cleanup()}return i}async function Te(e,t,n){let i=Ee(e.cmd),a=[...n,...i],o=r({passthrough:!1});o.start();let s=!0;try{let{runCommand:e}=await import(`./runner-
|
|
21
|
+
`)}function K(e,t){let n=o.resolve(e),r=o.dirname(n);a.existsSync(r)||a.mkdirSync(r,{recursive:!0}),a.writeFileSync(n,t,`utf-8`)}function be(e){let t=o.resolve(e);return a.existsSync(t)?a.readFileSync(t,`utf-8`):null}function xe(e,t=a){let n=o.resolve(e);t.existsSync(n)&&t.unlinkSync(n)}async function Se(e,n,r=[]){let a=t(e),o=a?.fields.filter(e=>e.positional)??[],s=a?.fields.filter(e=>!e.positional)??[],c=[];if(e.subCommands)for(let[t,n]of Object.entries(e.subCommands)){let e=await i(n),a=[...r,t];c.push({name:t,description:e.description,aliases:e.aliases,fullPath:a})}return{name:e.name??``,description:e.description,aliases:e.aliases,fullCommandPath:r.length>0?`${n} ${r.join(` `)}`:n,commandPath:r.join(` `),depth:r.length+1,positionalArgs:o,options:s,subCommands:c,extracted:a,command:e,notes:e.notes,examples:e.examples}}async function Ce(e,t){let n=t??e.name??`command`,r=new Map;async function a(e,t){let o=await Se(e,n,t),s=t.join(` `);if(r.set(s,o),e.subCommands)for(let[n,r]of Object.entries(e.subCommands))await a(await i(r),[...t,n])}return await a(e,[]),r}async function we(e,t,n,r=[]){let i=[];t.mock&&await t.mock();try{for(let t of e){let e=await Te(t,n,r);i.push(e)}}finally{t.cleanup&&await t.cleanup()}return i}async function Te(e,t,n){let i=Ee(e.cmd),a=[...n,...i],o=r({passthrough:!1});o.start();let s=!0;try{let{runCommand:e}=await import(`./runner-DPQ3GQA7.js`),n=await e(t,a);s=n.success,!n.success&&n.error&&console.error(n.error.message)}catch(e){s=!1,console.error(e instanceof Error?e.message:String(e))}finally{o.stop()}let c=o.getLogs(),l=c.entries.filter(e=>e.stream===`stdout`).map(e=>e.message).join(`
|
|
22
22
|
`),u=c.entries.filter(e=>e.stream===`stderr`).map(e=>e.message).join(`
|
|
23
23
|
`);return{cmd:e.cmd,desc:e.desc,expectedOutput:e.output,stdout:l,stderr:u,success:s}}function Ee(e){let t=[],n=``,r=!1,i=``;for(let a=0;a<e.length;a++){let o=e[a];(o===`"`||o===`'`)&&!r?(r=!0,i=o):o===i&&r?(r=!1,i=``):o===` `&&!r?n&&=(t.push(n),``):n+=o}return n&&t.push(n),t}function De(t){let n=e();return Object.entries(t).map(([e,t])=>n.resolveFieldMeta(e,t))}function Oe(e,t){let n=De(e).filter(e=>!e.positional);return n.length===0?``:C(p(n),t?.columns)}function ke(e){return e.replace(/\|/g,`\\|`).replace(/\n/g,` `)}function Ae(e){return e.replace(/\s+/g,`-`).toLowerCase()}function je(e){return e.subCommands.length===0}function Me(e,t){return e===t?!0:t===``?e!==``:e.startsWith(t+` `)}function Ne(e,t,n){let r=[];for(let i of e){let e=t.get(i);if(e){if(je(e))r.push(i);else for(let[e,a]of t)(i===``?e.length>0:e.startsWith(i+` `)||e===i)&&(je(a)||!n)&&r.push(e)}}return r}function Pe(e,t,n,r){let i=`#`.repeat(n),a=[];a.push(`${i} [${e.title}](${e.docPath})`),a.push(``),a.push(e.description),a.push(``);let o=e.noExpand?e.commands:Ne(e.commands,t,r),s=o,c=new Set;if(e.allowedCommands){let t=new Set(e.allowedCommands);s=o.filter(e=>t.has(e));for(let n of e.commands)t.has(n)&&!s.some(e=>Me(e,n))&&(s.push(n),c.add(n))}a.push(`| Command | Description |`),a.push(`|---------|-------------|`);for(let n of s){let i=t.get(n);if(!i||!e.noExpand&&r&&!c.has(n)&&!je(i))continue;let o=n||i.name,s=Ae(o),l=ke(i.description??``);a.push(`| [${o}](${e.docPath}#${s}) | ${l} |`)}return a.join(`
|
|
24
24
|
`)}async function Fe(e,t,n){let r=n?.headingLevel??3,i=n?.leafOnly??!0,a=await Ce(e),o=[];for(let e of t){let t=Pe(e,a,r,i);o.push(t)}return o.join(`
|
|
@@ -80,8 +80,8 @@ import{a as e}from"./field-meta-COGya7xp.js";import"./register-C1WbbeYH.js";impo
|
|
|
80
80
|
`+f+`
|
|
81
81
|
`,d=!0,{content:c,diffs:l,hasError:u,wasUpdated:d}):(u=!0,l.push(`${t} marker not found in file. Expected markers:\n${n}\n...\n${r}`),{content:c,diffs:l,hasError:u,wasUpdated:d});if(p!==f){if(a){let e=Mt(c,n,r,f);e?(c=e,d=!0):(u=!0,l.push(`Failed to replace ${t} section`))}else u=!0,l.push(G(p,f))}return{content:c,diffs:l,hasError:u,wasUpdated:d}}async function $t(e,t,n,r,i,a,o){let s=e,c=[],l=!1,u=!1,d=L(r),f=ie(r),p=s.includes(d),m=s.includes(f);if(!p&&!m)return{content:s,diffs:c,hasError:l,wasUpdated:u};if(!p||!m)return l=!0,c.push(`Index marker section is malformed: both start and end markers are required.`),{content:s,diffs:c,hasError:l,wasUpdated:u};let h=jt(s,d,f);if(!h)return l=!0,c.push(`Index marker section is malformed: start marker must appear before end marker.`),{content:s,diffs:c,hasError:l,wasUpdated:u};let g=await q(await Xt(t,n,r,o),a);if(h!==g){if(i){let e=Mt(s,d,f,g);e?(s=e,u=!0):(l=!0,c.push(`Failed to replace index section`))}else l=!0,c.push(G(h,g))}return{content:s,diffs:c,hasError:l,wasUpdated:u}}function en(e,t,n,r){for(let[i,a]of Object.entries(t)){let{commandPaths:t}=X(a,n,r);if(t.includes(e))return i}return null}function tn(e,t,n,r,i){let a=n[t];if(!a)return[];let{specifiedCommands:o,commandPaths:s}=X(a,r,i),c=new Set;for(let t of e)if(s.includes(t)){c.add(t);for(let e of s)J(e,t)&&!o.includes(e)&&c.add(e)}return Array.from(c)}function nn(e,t,n,r,i,a,o,s=[],c,l){let u=t.get(e);if(!u||l&&Ct(u.commandPath,l.commandScopes))return null;let d={...u,filePath:r,fileMap:i,rootDocPath:a};(s.length>0||l&&l.commandScopes.size>0)&&(d.subCommands=u.subCommands.filter(e=>{let t=e.fullPath.join(` `);return!s.some(e=>Ze(t,e))&&!(l&&Ct(t,l.commandScopes))})),o!==void 0&&(d.hasGlobalOptions=o),c&&c.size>0&&(d.options=u.options.filter(e=>!c.has(e.name)),u.extracted&&(d.extracted=an(u.extracted,c)));let f=n(d);if(l){for(let[e,t]of l.commandSections)if(e===u.commandPath){for(let n of t){let t=Q(f,n,e);t!==null&&(f=f.replace(t,``))}f=mt(f)}}return f}function rn(e,t,n,r,i,a,o,s,c,l){let u=Tt(e,t,r,l),d=[];for(let e of u){let u=nn(e,t,n,i,a,o,s,r,c,l);u!==null&&d.push(u)}return d.length===0?null:d.join(`
|
|
82
82
|
`)}function an(e,t){let n={...e,fields:e.fields.filter(e=>!t.has(e.name))};return e.unionOptions&&(n.unionOptions=e.unionOptions.map(e=>an(e,t))),e.variants&&(n.variants=e.variants.map(e=>({...e,fields:e.fields.filter(e=>!t.has(e.name))}))),n}function on(e,t,n,r,i,a,o,s,c,l=[]){let u=[],d=o?it(o):null;d&&u.push(d);let f=rt(e,a??[]);for(let e of f){let a=nn(e,t,n,r,i,s,c,l);a&&u.push(a)}return`${u.join(`
|
|
83
|
-
`)}\n`}function sn(e,t,n){let r={};for(let[i,a]of Object.entries(e)){let{commandPaths:e}=X(a,t,n);for(let t of e)qe(r,t,i)}return r}async function cn(e,t,n){for(let[r,i]of Object.entries(t)){let t=e.get(r);if(!t?.examples?.length)continue;let a=i===!0?{}:i,o=r?r.split(` `):[];t.exampleResults=await we(t.examples,a,n,o)}}function ln(e,t){if(typeof e==`string`)return{files:{[e]:Array.from(t.keys())},rootDocPath:e};let{root:n,commands:r={}}=e,i={},a=new Set,o=Object.entries(r).sort(([e],[t])=>t.split(` `).length-e.split(` `).length);for(let[e,n]of o){i[n]||(i[n]={commands:[],noExpand:!0});let r=i[n];for(let n of t.keys())(n===e||n.startsWith(e+` `))&&!a.has(n)&&(r.commands.push(n),a.add(n))}return i[n]={commands:Array.from(t.keys()).filter(e=>!a.has(e)),noExpand:!0},{files:i,rootDocPath:n}}async function un(e){let{command:t,ignores:r=[],format:i={},formatter:a,examples:s,targetCommands:c,globalArgs:l,customizable:u=!1}=e,d=await Ce(t),f,p=!1,m;if(e.path!==void 0){if(e.files!==void 0)throw Error(`Cannot specify both "path" and "files". Use one or the other.`);let t=ln(e.path,d);f=t.files,m=t.rootDocPath,p=!0}else if(e.files!==void 0)f=e.files;else if(e.templates!==void 0)f={};else throw Error(`Either "path", "files", or "templates" must be specified.`);let h=e.rootDoc;if(!h&&p&&(l||e.rootInfo)&&(h={path:m}),l&&h&&!h.globalOptions){let e=n(l).fields.filter(e=>!e.positional);if(e.length>0){let t=Object.fromEntries(e.map(e=>[e.name,e.schema]));h={...h,globalOptions:t}}}let g=Ie(T),_=Ie(E),v=!1;if(h&&!p){let e=$(h.path);if(Object.keys(f).some(t=>$(t)===e))throw Error(`rootDoc.path "${h.path}" must not also appear as a key in files.`)}s&&await cn(d,s,t);let y=c!==void 0&&c.length>0,b=zt(h),x=new Map;if(e.templates){if(b.size>0)for(let[e,t]of b)x.set(e,t);else{let e=Rt(l);if(e)for(let t of Ft(e))x.set(t.name,t)}}let S=y?Ut(c,f,d,r):Ht(f,d,r),C=[];for(let e of Object.values(f)){let t=Je(e);C.push(...t.commands)}nt(r,d),tt(C,r,d);let w=sn(f,d,r),D=new Map,O=new Map;if(e.templates)for(let[t,n]of Object.entries(e.templates)){let e=be(n);D.set(t,e),e!==null&&O.set(t,St(We(e),d))}let j=Object.entries(e.templates??{}),M=new Map,N=new Map;if(j.length>0){let e=h?$(h.path):null,t=new Set(Object.keys(f).map($)),n=new Set,i=new Set(j.map(([e])=>$(e)));for(let[r,a]of j){let o=$(r),s=$(a);if(t.has(o))throw Error(`Template output path "${r}" conflicts with an existing files key.`);if(e&&o===e)throw Error(`Template output path "${r}" conflicts with rootDoc.path "${h.path}".`);if(n.has(o))throw Error(`Duplicate template output path: "${r}".`);if(n.add(o),s===o)throw Error(`Template output path "${r}" must not be the same as its source template path.`);if(t.has(s))throw Error(`Template source path "${a}" conflicts with a files output key.`);if(e&&s===e)throw Error(`Template source path "${a}" conflicts with rootDoc.path "${h.path}".`);if(i.has(s))throw Error(`Template source path "${a}" conflicts with a template output path.`)}let a=Array.from(d.keys()).join(`, `);for(let[e,t]of j){let n=D.get(e)??null,i=[];if(n===null){M.set(e,{referencedScopes:[],headingScopes:[],commandTreeRoots:[],emitsGlobalOptions:!1,emitsIndex:!1}),N.set(e,i);continue}try{kt(n,t)}catch(e){i.push(e instanceof Error?e.message:String(e))}let o=Array.from(new Set(n.match(Ot)??[])),s=new Set,c=new Set,u=new Set,f=!1,p=!1,m=O.get(e)??Ke(new Set),g=Ge(n);for(let e of o){let n=Ve(e);if(m.rawKeys.has(n)||Dt(n,m))continue;let o=xt(e,d);if(!Et(e,o,m)){if(o.kind===`invalid`){i.push(`${o.reason} (in template "${t}")`);continue}if(o.kind===`command`){let{scope:e,type:n}=o;if(!d.has(e)){let n=At(e,d);if(n){i.push(`${n} (in template "${t}")`);continue}i.push(`Unknown command scope "${e}" in template "${t}". Available: ${a}`);continue}if(r.some(t=>Ze(e,t))){i.push(`Command scope "${e}" in template "${t}" conflicts with ignores configuration.`);continue}if(n===void 0){let t=Tt(e,d,r,m);wt(e,`heading`,m)||u.add(e);for(let e of t)s.add(e),wt(e,`heading`,m)||c.add(e)}else s.add(e),n===`heading`&&!wt(e,`heading`,m)&&(c.add(e),u.add(e))}else o.kind===`global-options`?f=!0:o.kind===`index`&&(p=!0)}}f&&(h?.globalOptions||Rt(l)!==void 0||i.push(`Template "${t}" uses {{politty:global-options}} but no global options are configured (neither rootDoc.globalOptions nor globalArgs with non-positional options).`)),M.set(e,{referencedScopes:Array.from(s),headingScopes:Array.from(c),commandTreeRoots:Array.from(u),emitsGlobalOptions:f,emitsIndex:p,...g.title===void 0?{}:{indexTitle:g.title},...g.description===void 0?{}:{indexDescription:g.description}}),N.set(e,i)}for(let e of M.values())if(!
|
|
84
|
-
`));let F=Array.from(M.entries()).filter(([,e])=>e.emitsGlobalOptions).map(([e])=>e),I=F.length===1?F[0]:void 0;if(qt(S,d,b),b.size===0&&x.size>0){let e=new Set;for(let t of P.values())if(
|
|
83
|
+
`)}\n`}function sn(e,t,n){let r={};for(let[i,a]of Object.entries(e)){let{commandPaths:e}=X(a,t,n);for(let t of e)qe(r,t,i)}return r}async function cn(e,t,n){for(let[r,i]of Object.entries(t)){let t=e.get(r);if(!t?.examples?.length)continue;let a=i===!0?{}:i,o=r?r.split(` `):[];t.exampleResults=await we(t.examples,a,n,o)}}function ln(e,t){if(typeof e==`string`)return{files:{[e]:Array.from(t.keys())},rootDocPath:e};let{root:n,commands:r={}}=e,i={},a=new Set,o=Object.entries(r).sort(([e],[t])=>t.split(` `).length-e.split(` `).length);for(let[e,n]of o){i[n]||(i[n]={commands:[],noExpand:!0});let r=i[n];for(let n of t.keys())(n===e||n.startsWith(e+` `))&&!a.has(n)&&(r.commands.push(n),a.add(n))}return i[n]={commands:Array.from(t.keys()).filter(e=>!a.has(e)),noExpand:!0},{files:i,rootDocPath:n}}async function un(e){let{command:t,ignores:r=[],format:i={},formatter:a,examples:s,targetCommands:c,globalArgs:l,customizable:u=!1}=e,d=await Ce(t),f,p=!1,m;if(e.path!==void 0){if(e.files!==void 0)throw Error(`Cannot specify both "path" and "files". Use one or the other.`);let t=ln(e.path,d);f=t.files,m=t.rootDocPath,p=!0}else if(e.files!==void 0)f=e.files;else if(e.templates!==void 0)f={};else throw Error(`Either "path", "files", or "templates" must be specified.`);let h=e.rootDoc;if(!h&&p&&(l||e.rootInfo)&&(h={path:m}),l&&h&&!h.globalOptions){let e=n(l).fields.filter(e=>!e.positional);if(e.length>0){let t=Object.fromEntries(e.map(e=>[e.name,e.schema]));h={...h,globalOptions:t}}}let g=Ie(T),_=Ie(E),v=!1;if(h&&!p){let e=$(h.path);if(Object.keys(f).some(t=>$(t)===e))throw Error(`rootDoc.path "${h.path}" must not also appear as a key in files.`)}s&&await cn(d,s,t);let y=c!==void 0&&c.length>0,b=zt(h),x=new Map;if(e.templates){if(b.size>0)for(let[e,t]of b)x.set(e,t);else{let e=Rt(l);if(e)for(let t of Ft(e))x.set(t.name,t)}}let S=y?Ut(c,f,d,r):Ht(f,d,r),C=[];for(let e of Object.values(f)){let t=Je(e);C.push(...t.commands)}nt(r,d),tt(C,r,d);let w=sn(f,d,r),D=new Map,O=new Map;if(e.templates)for(let[t,n]of Object.entries(e.templates)){let e=be(n);D.set(t,e),e!==null&&O.set(t,St(We(e),d))}let j=Object.entries(e.templates??{}),M=new Map,N=new Map;if(j.length>0){let e=h?$(h.path):null,t=new Set(Object.keys(f).map($)),n=new Set,i=new Set(j.map(([e])=>$(e)));for(let[r,a]of j){let o=$(r),s=$(a);if(t.has(o))throw Error(`Template output path "${r}" conflicts with an existing files key.`);if(e&&o===e)throw Error(`Template output path "${r}" conflicts with rootDoc.path "${h.path}".`);if(n.has(o))throw Error(`Duplicate template output path: "${r}".`);if(n.add(o),s===o)throw Error(`Template output path "${r}" must not be the same as its source template path.`);if(t.has(s))throw Error(`Template source path "${a}" conflicts with a files output key.`);if(e&&s===e)throw Error(`Template source path "${a}" conflicts with rootDoc.path "${h.path}".`);if(i.has(s))throw Error(`Template source path "${a}" conflicts with a template output path.`)}let a=Array.from(d.keys()).join(`, `);for(let[e,t]of j){let n=D.get(e)??null,i=[];if(n===null){M.set(e,{referencedScopes:[],headingScopes:[],commandTreeRoots:[],emitsGlobalOptions:!1,emitsIndex:!1}),N.set(e,i);continue}try{kt(n,t)}catch(e){i.push(e instanceof Error?e.message:String(e))}let o=Array.from(new Set(n.match(Ot)??[])),s=new Set,c=new Set,u=new Set,f=!1,p=!1,m=O.get(e)??Ke(new Set),g=Ge(n);for(let e of o){let n=Ve(e);if(m.rawKeys.has(n)||Dt(n,m))continue;let o=xt(e,d);if(!Et(e,o,m)){if(o.kind===`invalid`){i.push(`${o.reason} (in template "${t}")`);continue}if(o.kind===`command`){let{scope:e,type:n}=o;if(!d.has(e)){let n=At(e,d);if(n){i.push(`${n} (in template "${t}")`);continue}i.push(`Unknown command scope "${e}" in template "${t}". Available: ${a}`);continue}if(r.some(t=>Ze(e,t))){i.push(`Command scope "${e}" in template "${t}" conflicts with ignores configuration.`);continue}if(n===void 0){let t=Tt(e,d,r,m);wt(e,`heading`,m)||u.add(e);for(let e of t)s.add(e),wt(e,`heading`,m)||c.add(e)}else s.add(e),n===`heading`&&!wt(e,`heading`,m)&&(c.add(e),u.add(e))}else o.kind===`global-options`?f=!0:o.kind===`index`&&(p=!0)}}f&&(h?.globalOptions||Rt(l)!==void 0||i.push(`Template "${t}" uses {{politty:global-options}} but no global options are configured (neither rootDoc.globalOptions nor globalArgs with non-positional options).`)),M.set(e,{referencedScopes:Array.from(s),headingScopes:Array.from(c),commandTreeRoots:Array.from(u),emitsGlobalOptions:f,emitsIndex:p,...g.title===void 0?{}:{indexTitle:g.title},...g.description===void 0?{}:{indexDescription:g.description}}),N.set(e,i)}for(let e of M.values())if(!y||Kt(e,c))for(let t of e.referencedScopes)S.add(t)}if(y)for(let e of c){let t=en(e,f,d,r),n=Array.from(M.values()).some(t=>Gt(t,[e]));if(!t&&!n)throw Error(`Target command "${e}" not found in any file or template configuration`)}let P=y&&e.templates?new Map(Array.from(M.entries()).filter(([,e])=>Kt(e,c))):M;for(let[e,t]of N.entries())if(t.length>0&&P.has(e))throw Error(t.join(`
|
|
84
|
+
`));let F=Array.from(M.entries()).filter(([,e])=>e.emitsGlobalOptions).map(([e])=>e),I=F.length===1?F[0]:void 0;if(qt(S,d,b),b.size===0&&x.size>0){let e=new Set;for(let t of P.values())if(t.emitsGlobalOptions||I!==void 0)for(let n of t.referencedScopes)e.add(n);qt(e,d,x)}if(b.size>0)for(let e of d.values())e.options=e.options.filter(e=>!b.has(e.name)),e.extracted&&=an(e.extracted,new Set(b.keys()));let L={};for(let[e,t]of Object.entries(w))qe(L,e,t);let ie=e=>e===``?0:e.split(` `).length,R=new Map;for(let[e,t]of M.entries())for(let n of t.headingScopes){if(Object.prototype.hasOwnProperty.call(w,n))continue;let r=-1;for(let e of t.commandTreeRoots)J(n,e)&&(r=Math.max(r,ie(e)));if(r<0)continue;let i=R.get(n);(!i||r>i.rootLen)&&R.set(n,{outputPath:e,rootLen:r})}for(let[e,{outputPath:t}]of R)qe(L,e,t);let z=[],B=!1;for(let[e,t]of Object.entries(f)){let{fileConfig:n,specifiedCommands:o,commandPaths:s}=X(t,d,r);if(o.length===0||s.length===0)continue;let l=y?tn(c,e,f,d,r):[];if(y&&l.length===0)continue;let m=`match`,x=[],S=Math.min(...s.map(e=>d.get(e)?.depth??1)),C=Math.max(1,(i?.headingLevel??1)-(S-1)),w=p&&h&&$(e)===$(h.path),D=p||u,O=W({...i,headingLevel:C,markerless:!D}),j=n.render??O;if(w||y&&D){let t=be(e),i=rt(s,o),c=y?l:s;for(let o of c){let s=nn(o,d,j,e,L,h?.path,b.size>0,r);if(!s)throw Error(`Target command "${o}" not found in commands`);let c=await q(s,a);if(!t){if(g){let r=o===``&&n?it(n):null,i=r?`${r}\n${c}`:c;K(e,i),t=i,m=`created`}else B=!0,m=`diff`,x.push(`File does not exist. Target command "${o}" section cannot be validated.`);continue}let l=lt(t,o);if(l.length===0){g?(t=dt(t,o,c,i),K(e,t),m!==`created`&&(m=`updated`)):(B=!0,m=`diff`,x.push(`Existing file does not contain section markers for command "${o}"`));continue}for(let n of l){let r=Q(t,n,o),i=Q(c,n,o);if(r){if(!i){let i=k(n,o)+`
|
|
85
85
|
`+A(n,o);if(r!==i){if(g){let r=st(t,n,o,i);if(!r)throw Error(`Failed to replace stale ${n} section for command "${o}"`);t=r.replace(/\n{3,}/g,`
|
|
86
86
|
|
|
87
87
|
`),K(e,t),m!==`created`&&(m=`updated`)}else B=!0,m=`diff`,x.push(G(r,i))}continue}if(r!==i){if(g){let r=st(t,n,o,i);if(r)t=r,K(e,t),m!==`created`&&(m=`updated`);else throw Error(`Failed to replace ${n} section for command "${o}"`)}else B=!0,m=`diff`,x.push(G(r,i))}}}if(_||u){let n=lt(c,o),r=new Set(l);for(let i of n){if(r.has(i))continue;let n=Q(c,i,o);n&&(_&&g?(t=ct(t,i,o,n),K(e,t),m!==`created`&&(m=`updated`)):_?(B=!0,v=!0,m=`diff`,x.push(`[doctor] Missing section marker "${i}" for command "${Z(o)}". Run with ${E}=true ${T}=true to insert.\n${n}`)):console.warn(`[politty] Missing "${i}" section for command "${Z(o)}" in ${e}. Run with ${E}=true ${T}=true to insert it, or leave it removed to opt that section out.`))}}}if(t){let n=ut(t),r=new Set(s);if(g){let i=!1;for(let e of n)r.has(e)||(t=ft(t,e),i=!0);i&&(K(e,t),m!==`created`&&(m=`updated`))}else for(let e of n)r.has(e)||(B=!0,m=`diff`,x.push(`Found orphaned section markers for deleted command "${Z(e)}"`))}}else{let t=await q(on(s,d,j,e,L,o,n,h?.path,b.size>0,r),a),i=ye(t,e);i.match||(g?(K(e,t),m=i.fileExists?`updated`:`created`):(B=!0,m=`diff`,i.diff&&x.push(i.diff)))}x.length>0&&(m=`diff`),z.push({path:e,status:m,diff:x.length>0?x.join(`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./dynamic-BK6Tq_FR.js";export{e as createDynamicCompleteCommand};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{i as e,n as t}from"./field-meta-D7G8a7IG.js";import{t as n}from"./schema-extractor-QpSHJvwI.js";import{n as r}from"./command-tLHaJHe6.js";import{c as i,i as a}from"./subcommand-router-D8GTMXYL.js";import{t as o}from"./schema-ohwvrBGz.js";import{execSync as s}from"node:child_process";function c(e,t,n){return{fieldName:e.name,isArrayOption:e.valueType===`array`,isGlobal:e.isGlobal===!0,resolvedDeps:u(e.valueCompletion,e.isGlobal===!0,t,n)}}function l(e,t,n){return{fieldName:e.name,isArrayOption:!1,isGlobal:!1,resolvedDeps:u(e.valueCompletion,!1,t,n)}}function u(e,t,n,r=[]){if(e?.type!==`expand`)return[];let i=new Set,a=new Set;for(let e of n)e.isGlobal===!0?i.add(e.name):a.add(e.name);for(let e of r)a.add(e.name);return e.dependsOn.map(e=>({name:e,isGlobal:t||i.has(e)&&!a.has(e)}))}function d(e){let t=`$'`;for(let n of e){let e=n.codePointAt(0);t+=n===`\\`?`\\\\`:n===`'`?`\\'`:n===`
|
|
2
|
+
`?`\\n`:n===`\r`?`\\r`:n===` `?`\\t`:e<32||e===127?`\\x${e.toString(16).padStart(2,`0`)}`:n}return t+=`'`,t}function f(e){return`'${e.replace(/'/g,`'\\''`)}'`}function p(e,t){let n=t.withSize?`%Y:%s`:`%Y`,r=t.withSize?`%m:%z`:`%m`,i=`stat -L -c '${n}' "${e}" 2>/dev/null`,a=`stat -L -f '${r}' "${e}" 2>/dev/null`;return t.shell===`fish`?`(${i}; or ${a})`:`$(${i} || ${a})`}function m(e){return e.length===1?`-${e}`:`--${e}`}function h(t,n){g(t,m(n)),n.length===1?g(t,`--${n}`):n.includes(`-`)&&g(t,`--${e(n)}`)}function g(e,t){e.includes(t)||e.push(t)}function _(t,n){let r=[`--${t}`];t.length===1&&r.push(`-${t}`),t.includes(`-`)&&r.push(`--${e(t)}`);for(let e of n??[])h(r,e);return r}function v(e){let t=new Set;for(let n of e)if(n.isGlobal===!0){n.cliName.length===1&&t.add(`-${n.cliName}`);for(let e of n.alias??[])e.length===1&&t.add(`-${e}`)}return t}function y(t,n,r,i){let a=new Set(_(t,n));if(r&&(a.add(`--${r}`),r.includes(`-`)&&a.add(`--${e(r)}`)),i?.frameOptions){if(i.isGlobal===!0){for(let e of i.frameOptions)if(e.isGlobal!==!0)for(let t of b(e.cliName,e.alias))a.delete(t)}else{let e=v(i.frameOptions);if(e.size>0){let t=new Set((n??[]).filter(e=>e.length===1).map(e=>`-${e}`));for(let n of e)t.has(n)||a.delete(n)}}}return[...a].map(e=>`"${e}"`)}function b(t,n){let r=[`--${t}`];t.includes(`-`)&&r.push(`--${e(t)}`);for(let e of n??[])h(r,e);return r}function x(e){let t=e.completion;if(t?.custom){let n=t.custom,r=[];if(n.expand&&r.push(`expand`),n.resolve&&r.push(`resolve`),n.choices&&n.choices.length>0&&r.push(`choices`),n.shellCommand&&r.push(`shellCommand`),r.length>1)throw Error(`Field "${e.name??`<unknown>`}": completion.custom may only specify one of choices, shellCommand, resolve, expand (got ${r.join(`, `)}).`);if(n.expand)return{type:`pending-expand`,spec:n.expand};if(n.resolve)return{type:`dynamic`,resolve:n.resolve};if(n.choices&&n.choices.length>0)return{type:`choices`,choices:n.choices};if(n.shellCommand)return{type:`command`,shellCommand:n.shellCommand}}if(t?.type){if(t.type===`file`)return t.matcher?{type:`file`,matcher:t.matcher}:t.extensions?{type:`file`,extensions:t.extensions}:{type:`file`};if(t.type===`directory`)return{type:`directory`};if(t.type===`none`)return{type:`none`}}if(e.enumValues&&e.enumValues.length>0)return{type:`choices`,choices:e.enumValues}}function S(e){if(e)return e.type===`pending-expand`?{type:`runtime-expand`,dependsOn:e.spec.dependsOn,enumerate:e.spec.enumerate}:e}function C(e){return e.args?w(e.args):[]}function w(e){return n(e).fields.filter(e=>!e.positional).map(e=>{let n=t(e);return{name:e.name,cliName:e.cliName,alias:n.length>0?n:void 0,negation:e.negationDisplay,negationDescription:e.negationDescription,description:e.description,takesValue:e.type!==`boolean`,valueType:e.type,required:e.required,defaultNegationAccepted:e.type===`boolean`&&e.negation===!0,valueCompletion:S(x(e))}})}function T(e){return new Set(_(e.cliName,e.alias))}function ee(e,t){let n=T(t);for(let t of e)for(let e of T(t))if(n.has(e))return t}function te(e,t,n){let r=new Set;if(t.length===0)return r;let i=new Set,a=(e,t)=>{I(n,e,t,i),r.add(e.name)},o=0;for(;o<e.length;){let i=e[o];if(i===`--`||!i.startsWith(`-`))break;if(!i.startsWith(`--`)&&i.length>2){let e=i.indexOf(`=`);if((e>=0?i.slice(1,e):i.slice(1)).length>1)break}let s=A(i),c=z(t,s);if(!c){if(P(t,s)){o++;continue}break}if(c.takesValue){if(j(i)){let e=i.indexOf(`=`);a(c,i.slice(e+1)),o++}else if(o+1<e.length){let t=e[o+1];if(t.startsWith(`-`)){o++;continue}a(c,t),o+=2}else break}else n[c.name]=!L(c,s),r.add(c.name),o++}return r}function ne(e,t){return t.valueType===`array`?Array.isArray(e)?e:[e]:Array.isArray(e)?e.at(-1):e}function E(e,t){return t.length===0?e:[...e,...t]}function D(e,t){let n=t.length-1;if(!(n<0))return e>n?n:e}function O(e){return e.args?n(e.args).fields.filter(e=>e.positional).map((e,t)=>({name:e.name,cliName:e.cliName,position:t,description:e.description,required:e.required,variadic:e.type===`array`,valueCompletion:S(x(e))})):[]}function re(e){if(!e.subCommands)return[];let t=[];for(let[n,r]of Object.entries(e.subCommands)){if(n.startsWith(`__`))continue;t.push(n);let e=i(r);e?.aliases&&t.push(...e.aliases)}return t}function ie(e,t){if(!e.subCommands)return null;let n=Object.hasOwn(e.subCommands,t)?e.subCommands[t]:void 0;if(n)return i(n);let r=a(e,t);return r?i(e.subCommands[r]):null}function k(e){return e.startsWith(`-`)}function A(e){if(e.startsWith(`--`)){let t=e.slice(2),n=t.indexOf(`=`);return{name:n>=0?t.slice(0,n):t,isLong:!0}}return e.startsWith(`-`)?{name:e.slice(1,2),isLong:!1}:{name:e,isLong:!0}}function j(e){return e.includes(`=`)}function M(t,n,r){if(!r||t.valueType!==`boolean`)return!1;let i=[t.cliName,...t.alias??[]];for(let t of i){let r=`no-${t}`;if(n===r||n===e(r))return!0}return!1}function N(e,t,n){return e.defaultNegationAccepted===!0&&M(e,t,n)}function P(e,t){return e.some(e=>e.defaultNegationAccepted!==!0&&M(e,t.name,t.isLong))}function F(t,n){return t!==void 0&&t.includes(`-`)&&e(t)===n}function I(e,t,n,r){if(t.valueType!==`array`){e[t.name]=n;return}if(r.has(t.name)){let r=e[t.name];e[t.name]=Array.isArray(r)?[...r,n]:[n]}else e[t.name]=[n],r.add(t.name)}function L(e,t){return t.isLong?e.negation!==void 0&&(e.negation===t.name||F(e.negation,t.name))?!0:N(e,t.name,t.isLong):!1}function R(e,t,n){if(e.cliName===t&&(n||e.cliName.length===1))return!0;if(e.alias){for(let r of e.alias)if(r===t&&(n||r.length===1))return!0}return n&&e.negation===t?!0:!n||t.length<=1?!1:F(e.cliName,t)||e.alias?.some(e=>F(e,t))?!0:F(e.negation,t)}function z(e,t){if(!t.isLong){let n=e.find(e=>e.isGlobal!==!0&&e.alias?.includes(t.name)===!0);if(n)return n;let r=e.find(e=>e.isGlobal===!0&&R(e,t.name,t.isLong));if(r)return r}return e.find(e=>R(e,t.name,t.isLong))||e.find(e=>N(e,t.name,t.isLong))}function B(e,t,n){let r=t,i=[],a=n?w(n).map(e=>({...e,isGlobal:!0})):[],o=new Set,s=!1,c=0,l={},u=[],d={},f=new Set,p=0,m=new Set,h=e=>{o.add(e.cliName);for(let t of e.alias??[])o.add(t);e.negation&&o.add(e.negation),s=!0},g=(e,t)=>{I(e.isGlobal===!0?d:l,e,t,m)},_=(e,t)=>{let n=e.isGlobal===!0?d:l;n[e.name]=!L(e,t)},v=0,y=E(C(r),a),b=!1;for(;v<e.length-1;){let t=e[v];if(!b&&t===`--`){b=!0,v++;continue}if(!b&&t.startsWith(`-`)&&!t.startsWith(`--`)&&t.length>2&&!t.includes(`=`)){s=!0;let e=Array.from(t.slice(1)),n=y.filter(e=>e.isGlobal!==!0);for(let t of e){let e=z(n,{name:t,isLong:!1});e&&!e.takesValue&&(h(e),_(e,{name:t,isLong:!1}))}v++;continue}if(!b&&k(t)){s=!0;let n=A(t),r=z(y,n);if(r){if(h(r),r.takesValue){if(j(t)){let e=t.indexOf(`=`);g(r,t.slice(e+1))}else if(v+1<e.length-1){let t=e[v+1];k(t)||(g(r,t),v++)}}else _(r,n)}v++;continue}let n=b?null:ie(r,t);if(n){i.push(t);let s=C(r),h=e.slice(p,v);for(let e of te(h,a,d))f.add(e);r=n,y=E(C(r),a);for(let e of Object.keys(l)){let t=s.find(t=>t.name===e),n=a.find(t=>t.name===e)??(t?ee(a,t):void 0);n&&(f.has(n.name)||(d[n.name]=ne(l[e],n)))}o.clear(),c=0,l={},u=[],m=new Set,p=v+1,v++;continue}u.push(t),c++,v++}let x=e[e.length-1]??``,S=e[e.length-2]??``,T=O(r),M=re(r);for(let e=0;e<T.length;e++){let t=T[e];if(t.variadic){l[t.name]=u.slice(e);break}e<u.length&&(l[t.name]=u[e])}let N,P,F;if(!b&&S&&k(S)&&!j(S)){let e=z(y,A(S));e&&e.takesValue?(N=`option-value`,P=e):x.startsWith(`-`)?N=`option-name`:(N=V(x,M,T,c),N===`positional`&&(F=c))}else if(!b&&x.startsWith(`-`)&&j(x)){let e=z(y,A(x));e&&e.takesValue?(N=`option-value`,P=e):N=`option-name`}else!b&&x.startsWith(`-`)?N=`option-name`:(N=V(x,M,T,c,b),N===`positional`&&(F=c));let R=[];if(P){if(P.valueType===`array`){let e=(P.isGlobal===!0?d:l)[P.name];R=Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}}else if(N===`positional`&&F!==void 0){let e=D(F,T);e!==void 0&&T[e]?.variadic&&(R=u.slice(e))}let B={...d,...l};return{subcommandPath:i,currentCommand:r,currentWord:x,previousWord:S,completionType:N,targetOption:P,positionalIndex:F,options:y,subcommands:M,positionals:T,usedOptions:o,hasAnyOptionBeenUsed:s,providedPositionalCount:c,parsedArgs:B,previousValues:R}}function V(e,t,n,r,i){return i?`positional`:t.length>0&&(t.filter(t=>t.startsWith(e)).length>0||e===``)?`subcommand`:r<n.length||n.length>0&&n[n.length-1].variadic?`positional`:`subcommand`}const H={Default:0,NoSpace:1,NoFileCompletion:2,FilterPrefix:4,KeepOrder:8,FileCompletion:16,DirectoryCompletion:32,Error:64};function U(e){if(!e.startsWith(`-`))return;let t=e.indexOf(`=`);if(!(t<=0))return e.slice(0,t+1)}async function W(e,t){switch(e.completionType){case`subcommand`:return ue(e);case`option-name`:return Y(e);case`option-value`:{let n=e.targetOption,r=n?U(e.currentWord):void 0;return X(r?{...e,currentWord:e.currentWord.slice(r.length)}:e,t,n?.name,n?.valueCompletion,void 0,n?.valueType===`array`)}case`positional`:{let n=G(e);return n?X(e,t,n.name,n.valueCompletion,n.description,!1):{candidates:[],directive:H.NoFileCompletion}}}}function G(e){let t=e.positionalIndex??0,n=D(t,e.positionals);if(n===void 0)return;let r=e.positionals[n];if(r)return n===t||r.variadic?r:void 0}function K(e){try{return s(e,{encoding:`utf-8`,timeout:5e3}).split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(e=>e.length>0).map(e=>({value:e,type:`value`}))}catch{return[]}}function q(e){return e?.type===`choices`?e.choices:void 0}function J(e,t){let n=e.options.find(e=>e.name===t&&e.isGlobal!==!0);if(n)return q(n.valueCompletion);let r=e.positionals.find(e=>e.name===t);return q(r?r.valueCompletion:e.options.find(e=>e.name===t&&e.isGlobal===!0)?.valueCompletion)}function ae(e,t){let n=!t.includes(`=`),r=n?oe(e):se(e,t);return{candidates:r,hasEqSuffix:n&&r.some(e=>e.value.endsWith(`=`))}}function oe(e){let t=new Set,n=[];for(let r of e){let e=r.value.indexOf(`=`);if(e<=0){n.push(r);continue}let i=r.value.slice(0,e+1);t.has(i)||(t.add(i),n.push({...r,value:i}))}return n}function se(e,t){let n=t.slice(0,t.indexOf(`=`)+1);return e.filter(e=>e.value!==n)}async function ce(e,t,n,r,i){let a=[],o=H.FilterPrefix,s,c;switch(e.type){case`choices`:if(e.choices)for(let t of e.choices)a.push({value:t,description:r,type:`value`});o|=H.NoFileCompletion;break;case`file`:e.matcher&&e.matcher.length>0?(c=e.matcher.filter(e=>e.trim().length>0),c.length===0&&(c=void 0,o|=H.FileCompletion)):e.extensions&&e.extensions.length>0?(s=Array.from(new Set(e.extensions.map(e=>e.trim().replace(/^\./,``)).filter(e=>e.length>0))),s.length===0&&(s=void 0,o|=H.FileCompletion)):o|=H.FileCompletion;break;case`directory`:o|=H.DirectoryCompletion;break;case`command`:e.shellCommand&&a.push(...K(e.shellCommand)),o|=H.NoFileCompletion;break;case`none`:o|=H.NoFileCompletion;break;case`dynamic`:try{let n=await e.resolve(t);for(let e of n.candidates){let t=typeof e==`string`?{value:e}:e;a.push({...t,type:`value`})}o=n.directive??H.FilterPrefix|H.NoFileCompletion}catch{o=H.NoFileCompletion|H.Error}break;case`expand`:o|=H.NoFileCompletion;break;case`runtime-expand`:{let r={},i=!1;for(let a of e.dependsOn){let e=t.parsedArgs[a],o=Array.isArray(e)?e[e.length-1]:e,s=J(n,a);if(typeof o!=`string`||s===void 0||!s.includes(o)){i=!0;break}r[a]=o}if(!i)try{let t=new Set;for(let n of e.enumerate(r)){let e=typeof n==`string`?{value:n}:n;t.has(e.value)||(t.add(e.value),a.push({...e,type:`value`}))}}catch{o=H.NoFileCompletion|H.Error;break}o|=H.NoFileCompletion;break}}if(e.type===`dynamic`||e.type===`expand`||e.type===`runtime-expand`){let n=ae(e.type===`runtime-expand`&&i===!0?le(a,t.previousValues):a,t.currentWord);return n.hasEqSuffix&&(o|=H.NoSpace),{candidates:n.candidates,directive:o,fileExtensions:s,fileMatchers:c}}return{candidates:a,directive:o,fileExtensions:s,fileMatchers:c}}function le(e,t){let n=new Set;for(let e of t){let t=e.indexOf(`=`);t>0&&n.add(e.slice(0,t))}return n.size===0?[...e]:e.filter(e=>{let t=e.value.indexOf(`=`);return t<=0||!n.has(e.value.slice(0,t))})}function ue(e){let t=[];for(let n of e.subcommands){let r=e.currentCommand.subCommands,o=r?.[n],s=o?void 0:a(e.currentCommand,n),c=o??(s?r?.[s]:void 0),l=c?i(c)?.description:void 0;t.push({value:n,description:l,type:`subcommand`})}if(t.length===0||e.currentWord.startsWith(`-`)){let n=Y(e);t.push(...n.candidates)}return{candidates:t,directive:H.FilterPrefix|H.NoFileCompletion}}function Y(e){let t=[],n=e.options.filter(t=>t.valueType===`array`||!(e.usedOptions.has(t.cliName)||t.alias&&t.alias.some(t=>e.usedOptions.has(t))||t.negation&&e.usedOptions.has(t.negation)));for(let e of n)t.push({value:`--${e.cliName}`,description:e.description,type:`option`}),e.negation&&t.push({value:`--${e.negation}`,description:e.negationDescription??e.description,type:`option`});return e.hasAnyOptionBeenUsed||t.push({value:`--help`,description:`Show help information`,type:`option`},{value:`--help-all`,description:`Show help with all subcommand options`,type:`option`},{value:`--help-json`,description:`Show help as JSON`,type:`option`}),{candidates:t,directive:H.FilterPrefix|H.NoFileCompletion}}function de(e,t,n){return{currentWord:e.currentWord,shell:t.shell,parsedArgs:fe(e.parsedArgs,n),previousValues:e.previousValues,subcommandPath:e.subcommandPath}}function fe(e,t){if(t===void 0||!(t in e))return e;let n={...e};return delete n[t],n}async function X(e,t,n,r,i,a){return r?ce(r,de(e,t,n),e,i,a):{candidates:[],directive:H.FilterPrefix}}function Z(e,t){switch(t.shell){case`bash`:return $(e,t);case`zsh`:return pe(e,t);case`fish`:return me(e,t)}}function Q(e,t){let n=`:${t.directive}`;t.fileExtensions&&t.fileExtensions.length>0&&(n+=`\t@ext:${t.fileExtensions.join(`,`)}`),t.fileMatchers&&t.fileMatchers.length>0&&(n+=`\t@matcher:${t.fileMatchers.join(`,`)}`),e.push(n)}function $(e,t){let n=((e.directive&H.FilterPrefix)!==0&&t.currentWord?e.candidates.filter(e=>e.value.startsWith(t.currentWord)):e.candidates).map(e=>t.inlinePrefix?`${t.inlinePrefix}${e.value}`:e.value);return Q(n,e),n.join(`
|
|
4
|
+
`)}function pe(e,t){let n=e.candidates.map(e=>{let t=e.value.replace(/:/g,`\\:`);return e.description?`${t}:${e.description.replace(/:/g,`\\:`)}`:t});return Q(n,e),n.join(`
|
|
5
|
+
`)}function me(e,t){let n=e.candidates.map(e=>e.description?`${e.value}\t${e.description}`:e.value);return Q(n,e),n.join(`
|
|
6
|
+
`)}function he(e,t,n){return r({name:`__complete`,args:o,async run(t){let r=B(t.args,e,n),i=r.completionType===`option-value`&&r.targetOption?U(r.currentWord):void 0,a=i?r.currentWord.slice(i.length):r.currentWord,o=Z(await W(r,{shell:t.shell}),{shell:t.shell,currentWord:a,inlinePrefix:i});console.log(o)}})}function ge(e){return!!e.subCommands?.__complete}export{W as a,d as c,b as d,c as f,p as g,f as h,H as i,_ as l,y as m,ge as n,B as o,l as p,Z as r,x as s,he as t,v as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e;function t(t){e=t}function n(){if(!e)throw Error('No validator adapter registered. Import politty through an adapter package (e.g. `import { defineCommand } from "@politty/zod"` or `from "politty"`) so the schema library integration is set up.');return e}const r=new Set([`help`,`help-all`,`help-json`,`version`]);function i(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1-$2`).toLowerCase()}function a(e){return e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function o(e){return!e.alias&&!e.hiddenAlias?[]:[...e.alias??[],...e.hiddenAlias??[]]}function s(e,t){let n=t.argMeta,a=n?.description??t.description,o=i(e),s=/^[A-Za-z0-9][A-Za-z0-9-]*$/,c=(t,n)=>{if(t==null)return;let r=(Array.isArray(t)?t:[t]).map(t=>{if(typeof t!=`string`)throw Error(`Invalid ${n} for field "${e}": expected string or string[], received ${typeof t}.`);let r=t.trim().replace(/^-+/,``);if(r.length===0||!s.test(r))throw Error(`Invalid ${n} "${t}" for field "${e}": aliases must match ${s}.`);return r}),i=Array.from(new Set(r));return i.length>0?i:void 0},l=c(n?.alias,`alias`),u=new Set(l??[]),d=c(n?.hiddenAlias,`hiddenAlias`)?.filter(e=>!u.has(e)),f=d&&d.length>0?d:void 0,p=t.type,m=n?.negation,h;if(m!=null){if(typeof m==`boolean`){if(p!==`boolean`)throw Error(`Invalid negation for field "${e}": negation can only be used on boolean fields.`);h=m}else{if(typeof m!=`string`)throw Error(`Invalid negation for field "${e}": expected string or boolean, received ${typeof m}.`);let t=m.trim().replace(/^-+/,``);if(t.length===0||!s.test(t))throw Error(`Invalid negation "${m}" for field "${e}": negation names must match ${s}.`);if(r.has(t))throw Error(`Invalid negation "${m}" for field "${e}": negation cannot use reserved built-in flag names (${[...r].map(e=>`--${e}`).join(`, `)}).`);if(p!==`boolean`)throw Error(`Invalid negation for field "${e}": negation can only be used on boolean fields.`);h=t}}let g=n?.negationDescription,_;if(g!=null){if(typeof g!=`string`)throw Error(`Invalid negationDescription for field "${e}": expected string, received ${typeof g}.`);if(h===!1)throw Error(`Invalid negationDescription for field "${e}": negationDescription cannot be used when negation is false.`);if(h===void 0)throw Error(`Invalid negationDescription for field "${e}": negationDescription requires \`negation\` to be set (string or true).`);let t=g.trim();if(t.length===0)throw Error(`Invalid negationDescription for field "${e}": negationDescription must be a non-empty string.`);_=t}let v=typeof h==`string`?h:h===!0?`no-${o}`:void 0,y={name:e,cliName:o,alias:l,hiddenAlias:f,description:a,positional:n?.positional??!1,placeholder:n?.placeholder,env:n?.env,required:t.required,defaultValue:t.defaultValue,type:p,schema:t.schema,enumValues:t.enumValues,completion:n?.completion,prompt:n?.prompt,negation:h,negationDisplay:v,negationDescription:_,effect:n?.effect};return n&&`overrideBuiltinAlias`in n&&n.overrideBuiltinAlias===!0&&(y.overrideBuiltinAlias=!0),y}export{i as a,a as i,o as n,n as o,s as r,t as s,r as t};
|