politty 0.4.14 → 0.4.15
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 +7 -1
- package/dist/{arg-registry-r5wYN6qd.d.cts → arg-registry-CB5gGtzp.d.cts} +3 -1
- package/dist/arg-registry-CB5gGtzp.d.cts.map +1 -0
- package/dist/{arg-registry-CkPDokIu.d.ts → arg-registry-Dw0f11Zc.d.ts} +3 -1
- package/dist/arg-registry-Dw0f11Zc.d.ts.map +1 -0
- package/dist/augment.d.cts +1 -1
- package/dist/augment.d.ts +1 -1
- package/dist/completion/index.cjs +1 -1
- package/dist/completion/index.d.cts +1 -1
- package/dist/completion/index.d.ts +1 -1
- package/dist/completion/index.js +1 -1
- package/dist/{completion-CAekGYS4.cjs → completion-B5fgnUGm.cjs} +84 -29
- package/dist/completion-B5fgnUGm.cjs.map +1 -0
- package/dist/{completion-yHz8Pdr7.js → completion-Ca5ESJlG.js} +70 -15
- package/dist/completion-Ca5ESJlG.js.map +1 -0
- package/dist/docs/index.cjs +41 -45
- package/dist/docs/index.cjs.map +1 -1
- package/dist/docs/index.d.cts +5 -1
- package/dist/docs/index.d.cts.map +1 -1
- package/dist/docs/index.d.ts +5 -1
- package/dist/docs/index.d.ts.map +1 -1
- package/dist/docs/index.js +34 -38
- package/dist/docs/index.js.map +1 -1
- package/dist/{index-DPswv0Vt.d.cts → index-C1gGgUeB.d.cts} +4 -2
- package/dist/index-C1gGgUeB.d.cts.map +1 -0
- package/dist/{index-BLySW_2k.d.ts → index-Dg9Fpz0R.d.ts} +4 -2
- package/dist/index-Dg9Fpz0R.d.ts.map +1 -0
- package/dist/index.cjs +10 -10
- package/dist/index.d.cts +6 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/{subcommand-router-C9ONv6Nq.cjs → log-collector-Cd2_mv87.cjs} +1 -59
- package/dist/log-collector-Cd2_mv87.cjs.map +1 -0
- package/dist/{subcommand-router--EUt6ftA.js → log-collector-Cu6MCtAx.js} +2 -43
- package/dist/log-collector-Cu6MCtAx.js.map +1 -0
- package/dist/prompt/clack/index.cjs +1 -1
- package/dist/prompt/clack/index.d.cts +1 -1
- package/dist/prompt/clack/index.d.ts +1 -1
- package/dist/prompt/index.d.cts +1 -1
- package/dist/prompt/index.d.ts +1 -1
- package/dist/prompt/inquirer/index.cjs +1 -1
- package/dist/prompt/inquirer/index.d.cts +1 -1
- package/dist/prompt/inquirer/index.d.ts +1 -1
- package/dist/{runner-CY5fOsSh.cjs → runner-CriXJlm4.cjs} +116 -54
- package/dist/runner-CriXJlm4.cjs.map +1 -0
- package/dist/{runner-DSZw1AsW.js → runner-DKAQBNNh.js} +76 -14
- package/dist/runner-DKAQBNNh.js.map +1 -0
- package/dist/{lazy-AGV9Pkt5.cjs → subcommand-router-CqZX3orq.cjs} +108 -2
- package/dist/subcommand-router-CqZX3orq.cjs.map +1 -0
- package/dist/{lazy-DiMJSDMB.js → subcommand-router-ENeCymvX.js} +78 -2
- package/dist/subcommand-router-ENeCymvX.js.map +1 -0
- package/package.json +10 -10
- package/dist/arg-registry-CkPDokIu.d.ts.map +0 -1
- package/dist/arg-registry-r5wYN6qd.d.cts.map +0 -1
- package/dist/completion-CAekGYS4.cjs.map +0 -1
- package/dist/completion-yHz8Pdr7.js.map +0 -1
- package/dist/index-BLySW_2k.d.ts.map +0 -1
- package/dist/index-DPswv0Vt.d.cts.map +0 -1
- package/dist/lazy-AGV9Pkt5.cjs.map +0 -1
- package/dist/lazy-DiMJSDMB.js.map +0 -1
- package/dist/runner-CY5fOsSh.cjs.map +0 -1
- package/dist/runner-DSZw1AsW.js.map +0 -1
- package/dist/subcommand-router--EUt6ftA.js.map +0 -1
- package/dist/subcommand-router-C9ONv6Nq.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ From simple scripts to complex CLI tools with subcommands, validation, and auto-
|
|
|
9
9
|
- **Zod Native**: Use Zod schemas directly for argument definition and validation
|
|
10
10
|
- **Type Safety**: Full TypeScript support with automatic type inference for parsed arguments
|
|
11
11
|
- **Flexible Argument Definition**: Support for positional arguments, flags, aliases, arrays, and environment variable fallbacks
|
|
12
|
-
- **Subcommands**: Build Git-style nested subcommands (with lazy loading support)
|
|
12
|
+
- **Subcommands**: Build Git-style nested subcommands (with lazy loading and alias support)
|
|
13
13
|
- **Lifecycle Management**: Guaranteed `setup` → `run` → `cleanup` execution order
|
|
14
14
|
- **Signal Handling**: Proper SIGINT/SIGTERM handling with guaranteed cleanup execution
|
|
15
15
|
- **Auto Help Generation**: Automatically generate help text from definitions
|
|
@@ -149,6 +149,7 @@ import { arg, defineCommand, runMain } from "politty";
|
|
|
149
149
|
const initCommand = defineCommand({
|
|
150
150
|
name: "init",
|
|
151
151
|
description: "Initialize a project",
|
|
152
|
+
aliases: ["i"],
|
|
152
153
|
args: z.object({
|
|
153
154
|
template: arg(z.string().default("default"), {
|
|
154
155
|
alias: "t",
|
|
@@ -163,6 +164,7 @@ const initCommand = defineCommand({
|
|
|
163
164
|
const buildCommand = defineCommand({
|
|
164
165
|
name: "build",
|
|
165
166
|
description: "Build the project",
|
|
167
|
+
aliases: ["b"],
|
|
166
168
|
args: z.object({
|
|
167
169
|
output: arg(z.string().default("dist"), {
|
|
168
170
|
alias: "o",
|
|
@@ -194,7 +196,9 @@ Example usage:
|
|
|
194
196
|
|
|
195
197
|
```bash
|
|
196
198
|
$ my-cli init -t react
|
|
199
|
+
$ my-cli i -t react # alias for init
|
|
197
200
|
$ my-cli build -o out -m
|
|
201
|
+
$ my-cli b -o out -m # alias for build
|
|
198
202
|
$ my-cli --help
|
|
199
203
|
```
|
|
200
204
|
|
|
@@ -246,6 +250,7 @@ Define a command.
|
|
|
246
250
|
| `name` | `string` | Command name |
|
|
247
251
|
| `description` | `string?` | Command description |
|
|
248
252
|
| `args` | `ZodSchema` | Argument schema |
|
|
253
|
+
| `aliases` | `string[]?` | Command aliases |
|
|
249
254
|
| `subCommands` | `Record<string, Command>?` | Subcommands |
|
|
250
255
|
| `setup` | `(context) => Promise<void>?` | Setup hook |
|
|
251
256
|
| `run` | `(args) => T?` | Run function |
|
|
@@ -393,6 +398,7 @@ The `playground/` directory contains many examples:
|
|
|
393
398
|
- `10-subcommands` - Subcommands
|
|
394
399
|
- `12-discriminated-union` - Discriminated Union
|
|
395
400
|
- `21-lazy-subcommands` - Lazy loading
|
|
401
|
+
- `26-command-alias` - Command aliases
|
|
396
402
|
|
|
397
403
|
## License
|
|
398
404
|
|
|
@@ -246,6 +246,8 @@ interface CommandBase<TArgsSchema extends ArgsSchema | undefined = undefined, TA
|
|
|
246
246
|
name: string;
|
|
247
247
|
/** Command description */
|
|
248
248
|
description?: string | undefined;
|
|
249
|
+
/** Alternative names for this command (used as subcommand aliases) */
|
|
250
|
+
aliases?: string[] | undefined;
|
|
249
251
|
/** Argument schema (preserves the original Zod schema type) */
|
|
250
252
|
args: TArgsSchema;
|
|
251
253
|
/** Subcommands */
|
|
@@ -681,4 +683,4 @@ declare function arg<T extends z.ZodType>(schema: T): T;
|
|
|
681
683
|
declare function arg<T extends z.ZodType, M extends ArgMeta<z.output<T>>>(schema: T, meta: ValidateArgMeta<M>): T;
|
|
682
684
|
//#endregion
|
|
683
685
|
export { RunResultSuccess as A, UnknownKeysMode as B, Logger as C, RunCommandOptions as D, PromptResolver as E, LazyCommand as F, getUnknownKeysMode as H, isLazyCommand as I, lazy as L, SetupContext as M, SubCommandValue as N, RunResult as O, SubCommandsRecord as P, ExtractedFields as R, LogStream as S, NonRunnableCommand as T, toCamelCase as U, extractFields as V, toKebabCase as W, GlobalCleanupContext as _, EffectContext as a, LogEntry as b, arg as c, CleanupContext as d, CollectedLogs as f, GlobalArgs as g, Example as h, CustomCompletion as i, RunnableCommand as j, RunResultFailure as k, AnyCommand as l, CommandBase as m, CompletionMeta as n, PromptMeta as o, Command as p, CompletionType as r, PromptType as s, ArgMeta as t, ArgsSchema as u, GlobalSetupContext as v, MainOptions as w, LogLevel as x, IsEmpty as y, ResolvedFieldMeta as z };
|
|
684
|
-
//# sourceMappingURL=arg-registry-
|
|
686
|
+
//# sourceMappingURL=arg-registry-CB5gGtzp.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arg-registry-CB5gGtzp.d.cts","names":[],"sources":["../src/core/schema-extractor.ts","../src/lazy.ts","../src/types.ts","../src/core/arg-registry.ts"],"mappings":";;;AAwCA;;;AAAA,UAAiB,iBAAA;EAwCF;EAtCb,IAAA;EA0CoC;EAxCpC,OAAA;EAwCwE;;;;;EAlCxE,KAAA;EAOA;;;;EAFA,WAAA;EAeA;EAbA,WAAA;EAiBA;EAfA,UAAA;EAeU;EAbV,WAAA;EAiBA;;;;EAZA,GAAA;EAkBA;EAhBA,QAAA;EAgBoC;EAdpC,YAAA;EAc6D;EAZ7D,IAAA;EAYwE;EAVxE,MAAA,EAAQ,CAAA,CAAE,OAAA;EAgBoB;EAd9B,oBAAA;EAgBQ;EAdR,UAAA;EAwBU;EAtBV,UAAA,GAAa,cAAA;EA0BE;EAxBf,MAAA,GAAS,UAAA;EAiCuB;EA/BhC,MAAA,KAAW,KAAA,WAAgB,OAAA,EAAS,aAAA,YAAyB,WAAA;AAAA;;;;UAM9C,eAAA;EAQf;EANA,MAAA,EAAQ,iBAAA;EAQG;EANX,MAAA,EAAQ,UAAA;EAQN;EANF,UAAA;EAOE;EALF,aAAA;EAQe;EANf,QAAA,GAAW,KAAA;IACT,kBAAA;IACA,MAAA,EAAQ,iBAAA;IACR,WAAA;EAAA;EAqBQ;EAlBV,YAAA,GAAe,eAAA;;EAEf,WAAA;EAgByB;AA6C3B;;;;;EAtDE,eAAA,EAAiB,eAAA;AAAA;;;;AA0MnB;;;KAjMY,eAAA;;AAmNZ;;;;;AA6UA;;iBAnfgB,kBAAA,CAAmB,MAAA,EAAQ,CAAA,CAAE,OAAA,GAAU,eAAA;;;ACzJvD;;;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AI,CAAA,CAAE,CAAA;EAElB,WAAA;AAAA;AAAA,KAGG,YAAA,MAAkB,CAAA;EAAY,KAAA;AAAA,IAAmB,CAAA;AAAA,KACjD,kBAAA,MAAwB,CAAA;EAAY,WAAA;AAAA,IAAyB,CAAA;;;;;;;KAQ7D,eAAA,MAAqB,CAAA;EAAY,oBAAA;AAAA,IAClC,CAAA,GACA,qBAAA,CAAsB,YAAA,CAAa,CAAA,kBACjC,sBAAA,CAAuB,CAAA,IACvB,qBAAA,CAAsB,kBAAA,CAAmB,CAAA,kBACvC,sBAAA,CAAuB,CAAA,IACvB,CAAA;AAAA,iBAEQ,GAAA,WAAc,CAAA,CAAE,OAAA,CAAA,CAAS,MAAA,EAAQ,CAAA,GAAI,CAAA;AAAA,iBACrC,GAAA,WAAc,CAAA,CAAE,OAAA,YAAmB,OAAA,CAAQ,CAAA,CAAE,MAAA,CAAO,CAAA,GAAA,CAClE,MAAA,EAAQ,CAAA,EACR,IAAA,EAAM,eAAA,CAAgB,CAAA,IACrB,CAAA"}
|
|
@@ -246,6 +246,8 @@ interface CommandBase<TArgsSchema extends ArgsSchema | undefined = undefined, TA
|
|
|
246
246
|
name: string;
|
|
247
247
|
/** Command description */
|
|
248
248
|
description?: string | undefined;
|
|
249
|
+
/** Alternative names for this command (used as subcommand aliases) */
|
|
250
|
+
aliases?: string[] | undefined;
|
|
249
251
|
/** Argument schema (preserves the original Zod schema type) */
|
|
250
252
|
args: TArgsSchema;
|
|
251
253
|
/** Subcommands */
|
|
@@ -681,4 +683,4 @@ declare function arg<T extends z.ZodType>(schema: T): T;
|
|
|
681
683
|
declare function arg<T extends z.ZodType, M extends ArgMeta<z.output<T>>>(schema: T, meta: ValidateArgMeta<M>): T;
|
|
682
684
|
//#endregion
|
|
683
685
|
export { RunResultSuccess as A, UnknownKeysMode as B, Logger as C, RunCommandOptions as D, PromptResolver as E, LazyCommand as F, getUnknownKeysMode as H, isLazyCommand as I, lazy as L, SetupContext as M, SubCommandValue as N, RunResult as O, SubCommandsRecord as P, ExtractedFields as R, LogStream as S, NonRunnableCommand as T, toCamelCase as U, extractFields as V, toKebabCase as W, GlobalCleanupContext as _, EffectContext as a, LogEntry as b, arg as c, CleanupContext as d, CollectedLogs as f, GlobalArgs as g, Example as h, CustomCompletion as i, RunnableCommand as j, RunResultFailure as k, AnyCommand as l, CommandBase as m, CompletionMeta as n, PromptMeta as o, Command as p, CompletionType as r, PromptType as s, ArgMeta as t, ArgsSchema as u, GlobalSetupContext as v, MainOptions as w, LogLevel as x, IsEmpty as y, ResolvedFieldMeta as z };
|
|
684
|
-
//# sourceMappingURL=arg-registry-
|
|
686
|
+
//# sourceMappingURL=arg-registry-Dw0f11Zc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arg-registry-Dw0f11Zc.d.ts","names":[],"sources":["../src/core/schema-extractor.ts","../src/lazy.ts","../src/types.ts","../src/core/arg-registry.ts"],"mappings":";;;AAwCA;;;AAAA,UAAiB,iBAAA;EAwCF;EAtCb,IAAA;EA0CoC;EAxCpC,OAAA;EAwCwE;;;;;EAlCxE,KAAA;EAOA;;;;EAFA,WAAA;EAeA;EAbA,WAAA;EAiBA;EAfA,UAAA;EAeU;EAbV,WAAA;EAiBA;;;;EAZA,GAAA;EAkBA;EAhBA,QAAA;EAgBoC;EAdpC,YAAA;EAc6D;EAZ7D,IAAA;EAYwE;EAVxE,MAAA,EAAQ,CAAA,CAAE,OAAA;EAgBoB;EAd9B,oBAAA;EAgBQ;EAdR,UAAA;EAwBU;EAtBV,UAAA,GAAa,cAAA;EA0BE;EAxBf,MAAA,GAAS,UAAA;EAiCuB;EA/BhC,MAAA,KAAW,KAAA,WAAgB,OAAA,EAAS,aAAA,YAAyB,WAAA;AAAA;;;;UAM9C,eAAA;EAQf;EANA,MAAA,EAAQ,iBAAA;EAQG;EANX,MAAA,EAAQ,UAAA;EAQN;EANF,UAAA;EAOE;EALF,aAAA;EAQe;EANf,QAAA,GAAW,KAAA;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5B,WAAA;ED5JM;EC8JN,oBAAA;AAAA;ADxJF;;;AAAA,KC8JY,OAAA,qBAA4B,cAAA,CAAe,MAAA,IAAU,sBAAA,CAAuB,MAAA;;;ADnJxF;;;;;AAKA;;;;;AAUA;;;;;;;;;;;;;;;;KCwKK,qBAAA,OAA4B,CAAA,4BAE7B,CAAA,4BAEE,CAAA,iCACG,OAAA,CAAQ,CAAA;AAAA,KAKZ,sBAAA,oBACS,CAAA,GAAI,CAAA,CAAE,CAAA;EAElB,WAAA;AAAA;AAAA,KAGG,YAAA,MAAkB,CAAA;EAAY,KAAA;AAAA,IAAmB,CAAA;AAAA,KACjD,kBAAA,MAAwB,CAAA;EAAY,WAAA;AAAA,IAAyB,CAAA;;;;;;;KAQ7D,eAAA,MAAqB,CAAA;EAAY,oBAAA;AAAA,IAClC,CAAA,GACA,qBAAA,CAAsB,YAAA,CAAa,CAAA,kBACjC,sBAAA,CAAuB,CAAA,IACvB,qBAAA,CAAsB,kBAAA,CAAmB,CAAA,kBACvC,sBAAA,CAAuB,CAAA,IACvB,CAAA;AAAA,iBAEQ,GAAA,WAAc,CAAA,CAAE,OAAA,CAAA,CAAS,MAAA,EAAQ,CAAA,GAAI,CAAA;AAAA,iBACrC,GAAA,WAAc,CAAA,CAAE,OAAA,YAAmB,OAAA,CAAQ,CAAA,CAAE,MAAA,CAAO,CAAA,GAAA,CAClE,MAAA,EAAQ,CAAA,EACR,IAAA,EAAM,eAAA,CAAgB,CAAA,IACrB,CAAA"}
|
package/dist/augment.d.cts
CHANGED
package/dist/augment.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_completion = require('../completion-
|
|
2
|
+
const require_completion = require('../completion-B5fgnUGm.cjs');
|
|
3
3
|
|
|
4
4
|
exports.CompletionDirective = require_completion.CompletionDirective;
|
|
5
5
|
exports.createCompletionCommand = require_completion.createCompletionCommand;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as CompletableSubcommand, D as CompletionResult, E as CompletionOptions, O as ShellType, S as CompletableOption, T as CompletionGenerator, _ as CompletionDirective, a as getSupportedShells, b as CompletionType, c as resolveValueCompletion, d as ShellFormatOptions, f as formatForShell, g as CompletionCandidate, h as CandidateResult, i as generateCompletion, l as extractCompletionData, m as hasCompleteCommand, n as createCompletionCommand, o as withCompletionCommand, p as createDynamicCompleteCommand, r as detectShell, s as ValueCompletionField, t as WithCompletionOptions, u as extractPositionals, v as generateCandidates, w as CompletionData, x as parseCompletionContext, y as CompletionContext } from "../index-
|
|
1
|
+
import { C as CompletableSubcommand, D as CompletionResult, E as CompletionOptions, O as ShellType, S as CompletableOption, T as CompletionGenerator, _ as CompletionDirective, a as getSupportedShells, b as CompletionType, c as resolveValueCompletion, d as ShellFormatOptions, f as formatForShell, g as CompletionCandidate, h as CandidateResult, i as generateCompletion, l as extractCompletionData, m as hasCompleteCommand, n as createCompletionCommand, o as withCompletionCommand, p as createDynamicCompleteCommand, r as detectShell, s as ValueCompletionField, t as WithCompletionOptions, u as extractPositionals, v as generateCandidates, w as CompletionData, x as parseCompletionContext, y as CompletionContext } from "../index-C1gGgUeB.cjs";
|
|
2
2
|
export { CandidateResult, CompletableOption, CompletableSubcommand, CompletionCandidate, CompletionContext, CompletionData, CompletionDirective, CompletionGenerator, CompletionOptions, CompletionResult, CompletionType, ShellFormatOptions, ShellType, ValueCompletionField, WithCompletionOptions, createCompletionCommand, createDynamicCompleteCommand, detectShell, extractCompletionData, extractPositionals, formatForShell, generateCandidates, generateCompletion, getSupportedShells, hasCompleteCommand, parseCompletionContext, resolveValueCompletion, withCompletionCommand };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as CompletableSubcommand, D as CompletionResult, E as CompletionOptions, O as ShellType, S as CompletableOption, T as CompletionGenerator, _ as CompletionDirective, a as getSupportedShells, b as CompletionType, c as resolveValueCompletion, d as ShellFormatOptions, f as formatForShell, g as CompletionCandidate, h as CandidateResult, i as generateCompletion, l as extractCompletionData, m as hasCompleteCommand, n as createCompletionCommand, o as withCompletionCommand, p as createDynamicCompleteCommand, r as detectShell, s as ValueCompletionField, t as WithCompletionOptions, u as extractPositionals, v as generateCandidates, w as CompletionData, x as parseCompletionContext, y as CompletionContext } from "../index-
|
|
1
|
+
import { C as CompletableSubcommand, D as CompletionResult, E as CompletionOptions, O as ShellType, S as CompletableOption, T as CompletionGenerator, _ as CompletionDirective, a as getSupportedShells, b as CompletionType, c as resolveValueCompletion, d as ShellFormatOptions, f as formatForShell, g as CompletionCandidate, h as CandidateResult, i as generateCompletion, l as extractCompletionData, m as hasCompleteCommand, n as createCompletionCommand, o as withCompletionCommand, p as createDynamicCompleteCommand, r as detectShell, s as ValueCompletionField, t as WithCompletionOptions, u as extractPositionals, v as generateCandidates, w as CompletionData, x as parseCompletionContext, y as CompletionContext } from "../index-Dg9Fpz0R.js";
|
|
2
2
|
export { CandidateResult, CompletableOption, CompletableSubcommand, CompletionCandidate, CompletionContext, CompletionData, CompletionDirective, CompletionGenerator, CompletionOptions, CompletionResult, CompletionType, ShellFormatOptions, ShellType, ValueCompletionField, WithCompletionOptions, createCompletionCommand, createDynamicCompleteCommand, detectShell, extractCompletionData, extractPositionals, formatForShell, generateCandidates, generateCompletion, getSupportedShells, hasCompleteCommand, parseCompletionContext, resolveValueCompletion, withCompletionCommand };
|
package/dist/completion/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as withCompletionCommand, c as formatForShell, d as generateCandidates, f as extractCompletionData, i as getSupportedShells, l as parseCompletionContext, m as resolveValueCompletion, n as detectShell, o as createDynamicCompleteCommand, p as extractPositionals, r as generateCompletion, s as hasCompleteCommand, t as createCompletionCommand, u as CompletionDirective } from "../completion-
|
|
1
|
+
import { a as withCompletionCommand, c as formatForShell, d as generateCandidates, f as extractCompletionData, i as getSupportedShells, l as parseCompletionContext, m as resolveValueCompletion, n as detectShell, o as createDynamicCompleteCommand, p as extractPositionals, r as generateCompletion, s as hasCompleteCommand, t as createCompletionCommand, u as CompletionDirective } from "../completion-Ca5ESJlG.js";
|
|
2
2
|
|
|
3
3
|
export { CompletionDirective, createCompletionCommand, createDynamicCompleteCommand, detectShell, extractCompletionData, extractPositionals, formatForShell, generateCandidates, generateCompletion, getSupportedShells, hasCompleteCommand, parseCompletionContext, resolveValueCompletion, withCompletionCommand };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const require_log_collector = require('./log-collector-Cd2_mv87.cjs');
|
|
2
|
+
const require_subcommand_router = require('./subcommand-router-CqZX3orq.cjs');
|
|
3
3
|
let zod = require("zod");
|
|
4
4
|
let node_child_process = require("node:child_process");
|
|
5
5
|
|
|
@@ -8,6 +8,7 @@ function defineCommand(config) {
|
|
|
8
8
|
return {
|
|
9
9
|
name: config.name,
|
|
10
10
|
description: config.description,
|
|
11
|
+
aliases: config.aliases,
|
|
11
12
|
args: config.args,
|
|
12
13
|
subCommands: config.subCommands,
|
|
13
14
|
setup: config.setup,
|
|
@@ -112,6 +113,25 @@ function getVisibleSubs(subs) {
|
|
|
112
113
|
return subs.filter((s) => !s.name.startsWith("__"));
|
|
113
114
|
}
|
|
114
115
|
/**
|
|
116
|
+
* Get all completable subcommand names including aliases.
|
|
117
|
+
* Returns an array of { name, description } for all visible subcommands
|
|
118
|
+
* and their aliases.
|
|
119
|
+
*/
|
|
120
|
+
function getSubNamesWithAliases(subs) {
|
|
121
|
+
const result = [];
|
|
122
|
+
for (const sub of getVisibleSubs(subs)) {
|
|
123
|
+
result.push({
|
|
124
|
+
name: sub.name,
|
|
125
|
+
description: sub.description
|
|
126
|
+
});
|
|
127
|
+
if (sub.aliases) for (const alias of sub.aliases) result.push({
|
|
128
|
+
name: alias,
|
|
129
|
+
description: sub.description
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
115
135
|
* Convert a resolved field to a completable option
|
|
116
136
|
*/
|
|
117
137
|
function fieldToOption(field) {
|
|
@@ -131,21 +151,21 @@ function fieldToOption(field) {
|
|
|
131
151
|
*/
|
|
132
152
|
function extractOptions$1(command) {
|
|
133
153
|
if (!command.args) return [];
|
|
134
|
-
return
|
|
154
|
+
return require_subcommand_router.extractFields(command.args).fields.filter((field) => !field.positional).map(fieldToOption);
|
|
135
155
|
}
|
|
136
156
|
/**
|
|
137
157
|
* Extract positional arguments from a command
|
|
138
158
|
*/
|
|
139
159
|
function extractPositionals(command) {
|
|
140
160
|
if (!command.args) return [];
|
|
141
|
-
return
|
|
161
|
+
return require_subcommand_router.extractFields(command.args).fields.filter((field) => field.positional);
|
|
142
162
|
}
|
|
143
163
|
/**
|
|
144
164
|
* Extract completable positional arguments from a command
|
|
145
165
|
*/
|
|
146
166
|
function extractCompletablePositionals(command) {
|
|
147
167
|
if (!command.args) return [];
|
|
148
|
-
return
|
|
168
|
+
return require_subcommand_router.extractFields(command.args).fields.filter((field) => field.positional).map((field, index) => ({
|
|
149
169
|
name: field.name,
|
|
150
170
|
cliName: field.cliName,
|
|
151
171
|
position: index,
|
|
@@ -161,7 +181,7 @@ function extractCompletablePositionals(command) {
|
|
|
161
181
|
function extractSubcommand(name, command) {
|
|
162
182
|
const subcommands = [];
|
|
163
183
|
if (command.subCommands) for (const [subName, subCommand] of Object.entries(command.subCommands)) {
|
|
164
|
-
const resolved =
|
|
184
|
+
const resolved = require_subcommand_router.resolveSubCommandMeta(subCommand);
|
|
165
185
|
if (resolved) subcommands.push(extractSubcommand(subName, resolved));
|
|
166
186
|
else subcommands.push({
|
|
167
187
|
name: subName,
|
|
@@ -174,6 +194,7 @@ function extractSubcommand(name, command) {
|
|
|
174
194
|
return {
|
|
175
195
|
name,
|
|
176
196
|
description: command.description,
|
|
197
|
+
aliases: command.aliases,
|
|
177
198
|
subcommands,
|
|
178
199
|
options: extractOptions$1(command),
|
|
179
200
|
positionals: extractCompletablePositionals(command)
|
|
@@ -195,13 +216,17 @@ function optTakesValueEntries(sub, parentPath) {
|
|
|
195
216
|
if (opt.alias) for (const a of opt.alias) patterns.push(`${parentPath}:${a.length === 1 ? `-${a}` : `--${a}`}`);
|
|
196
217
|
lines.push(` ${patterns.join("|")}) return 0 ;;`);
|
|
197
218
|
}
|
|
198
|
-
for (const child of getVisibleSubs(sub.subcommands))
|
|
219
|
+
for (const child of getVisibleSubs(sub.subcommands)) {
|
|
220
|
+
lines.push(...optTakesValueEntries(child, joinPrefix(parentPath, child.name, ":")));
|
|
221
|
+
if (child.aliases) for (const alias of child.aliases) lines.push(...optTakesValueEntries(child, joinPrefix(parentPath, alias, ":")));
|
|
222
|
+
}
|
|
199
223
|
return lines;
|
|
200
224
|
}
|
|
201
225
|
/**
|
|
202
226
|
* Recursively collect all subcommand route entries.
|
|
203
227
|
* Returns entries used by all shell generators for both dispatch routing
|
|
204
228
|
* and subcommand lookup (is_subcmd) tables.
|
|
229
|
+
* Aliases are mapped to the same handler as the canonical name.
|
|
205
230
|
*/
|
|
206
231
|
function collectRouteEntries(sub, parentPath = "", parentFunc = "") {
|
|
207
232
|
const entries = [];
|
|
@@ -214,6 +239,15 @@ function collectRouteEntries(sub, parentPath = "", parentFunc = "") {
|
|
|
214
239
|
funcSuffix,
|
|
215
240
|
lookupPattern: `${parentPath}:${child.name}`
|
|
216
241
|
});
|
|
242
|
+
if (child.aliases) for (const alias of child.aliases) {
|
|
243
|
+
const aliasPathStr = joinPrefix(parentPath, alias, ":");
|
|
244
|
+
entries.push(...collectRouteEntries(child, aliasPathStr, funcSuffix));
|
|
245
|
+
entries.push({
|
|
246
|
+
pathStr: aliasPathStr,
|
|
247
|
+
funcSuffix,
|
|
248
|
+
lookupPattern: `${parentPath}:${alias}`
|
|
249
|
+
});
|
|
250
|
+
}
|
|
217
251
|
}
|
|
218
252
|
return entries;
|
|
219
253
|
}
|
|
@@ -246,7 +280,7 @@ function extractCompletionData(command, programName, globalArgsSchema) {
|
|
|
246
280
|
const rootSubcommand = extractSubcommand(programName, command);
|
|
247
281
|
let globalOptions;
|
|
248
282
|
if (globalArgsSchema) {
|
|
249
|
-
globalOptions =
|
|
283
|
+
globalOptions = require_subcommand_router.extractFields(globalArgsSchema).fields.filter((field) => !field.positional).map(fieldToOption);
|
|
250
284
|
propagateGlobalOptions(rootSubcommand, globalOptions);
|
|
251
285
|
} else globalOptions = rootSubcommand.options;
|
|
252
286
|
return {
|
|
@@ -417,7 +451,7 @@ function generateSubHandler$2(sub, fn, path) {
|
|
|
417
451
|
lines.push(` return`);
|
|
418
452
|
lines.push(` fi`);
|
|
419
453
|
if (visibleSubs.length > 0) {
|
|
420
|
-
const subNames =
|
|
454
|
+
const subNames = getSubNamesWithAliases(sub.subcommands).map((s) => s.name).join(" ");
|
|
421
455
|
lines.push(` COMPREPLY=($(compgen -W "${subNames}" -- "$_cur"))`);
|
|
422
456
|
lines.push(` compopt +o default 2>/dev/null`);
|
|
423
457
|
} else if (sub.positionals.length > 0) lines.push(...positionalBlock$2(sub.positionals));
|
|
@@ -479,7 +513,7 @@ function generateBashCompletion(command, options) {
|
|
|
479
513
|
lines.push(` compopt +o default 2>/dev/null`);
|
|
480
514
|
if (visibleSubs.length > 0) {
|
|
481
515
|
lines.push(` else`);
|
|
482
|
-
const subNames =
|
|
516
|
+
const subNames = getSubNamesWithAliases(root.subcommands).map((s) => s.name).join(" ");
|
|
483
517
|
lines.push(` COMPREPLY=($(compgen -W "${subNames}" -- "$_cur"))`);
|
|
484
518
|
lines.push(` compopt +o default 2>/dev/null`);
|
|
485
519
|
} else if (root.positionals.length > 0) {
|
|
@@ -668,8 +702,16 @@ function generateSubcommandCandidates(context) {
|
|
|
668
702
|
const candidates = [];
|
|
669
703
|
let directive = CompletionDirective.FilterPrefix;
|
|
670
704
|
for (const name of context.subcommands) {
|
|
705
|
+
let description;
|
|
671
706
|
const sub = context.currentCommand.subCommands?.[name];
|
|
672
|
-
|
|
707
|
+
if (sub) description = require_subcommand_router.resolveSubCommandMeta(sub)?.description;
|
|
708
|
+
else {
|
|
709
|
+
const canonical = require_subcommand_router.resolveSubCommandAlias(context.currentCommand, name);
|
|
710
|
+
if (canonical) {
|
|
711
|
+
const resolved = context.currentCommand.subCommands?.[canonical];
|
|
712
|
+
if (resolved) description = require_subcommand_router.resolveSubCommandMeta(resolved)?.description;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
673
715
|
candidates.push({
|
|
674
716
|
value: name,
|
|
675
717
|
description,
|
|
@@ -763,7 +805,7 @@ function generatePositionalCandidates(context) {
|
|
|
763
805
|
*/
|
|
764
806
|
function extractOptions(command) {
|
|
765
807
|
if (!command.args) return [];
|
|
766
|
-
return
|
|
808
|
+
return require_subcommand_router.extractFields(command.args).fields.filter((field) => !field.positional).map((field) => ({
|
|
767
809
|
name: field.name,
|
|
768
810
|
cliName: field.cliName,
|
|
769
811
|
alias: field.alias,
|
|
@@ -779,7 +821,7 @@ function extractOptions(command) {
|
|
|
779
821
|
*/
|
|
780
822
|
function extractPositionalsForContext(command) {
|
|
781
823
|
if (!command.args) return [];
|
|
782
|
-
return
|
|
824
|
+
return require_subcommand_router.extractFields(command.args).fields.filter((field) => field.positional).map((field, index) => ({
|
|
783
825
|
name: field.name,
|
|
784
826
|
cliName: field.cliName,
|
|
785
827
|
position: index,
|
|
@@ -790,20 +832,29 @@ function extractPositionalsForContext(command) {
|
|
|
790
832
|
}));
|
|
791
833
|
}
|
|
792
834
|
/**
|
|
793
|
-
* Get subcommand names from a command
|
|
835
|
+
* Get subcommand names from a command (including aliases)
|
|
794
836
|
*/
|
|
795
837
|
function getSubcommandNames(command) {
|
|
796
838
|
if (!command.subCommands) return [];
|
|
797
|
-
|
|
839
|
+
const names = [];
|
|
840
|
+
for (const [name, subCmd] of Object.entries(command.subCommands)) {
|
|
841
|
+
if (name.startsWith("__")) continue;
|
|
842
|
+
names.push(name);
|
|
843
|
+
const meta = require_subcommand_router.resolveSubCommandMeta(subCmd);
|
|
844
|
+
if (meta?.aliases) names.push(...meta.aliases);
|
|
845
|
+
}
|
|
846
|
+
return names;
|
|
798
847
|
}
|
|
799
848
|
/**
|
|
800
|
-
* Resolve subcommand by name
|
|
849
|
+
* Resolve subcommand by name (including alias lookup)
|
|
801
850
|
*/
|
|
802
851
|
function resolveSubcommand(command, name) {
|
|
803
852
|
if (!command.subCommands) return null;
|
|
804
853
|
const sub = command.subCommands[name];
|
|
805
|
-
if (
|
|
806
|
-
|
|
854
|
+
if (sub) return require_subcommand_router.resolveSubCommandMeta(sub);
|
|
855
|
+
const canonical = require_subcommand_router.resolveSubCommandAlias(command, name);
|
|
856
|
+
if (canonical) return require_subcommand_router.resolveSubCommandMeta(command.subCommands[canonical]);
|
|
857
|
+
return null;
|
|
807
858
|
}
|
|
808
859
|
/**
|
|
809
860
|
* Check if a word is an option (starts with - or --)
|
|
@@ -837,8 +888,8 @@ function findOption(options, nameOrAlias) {
|
|
|
837
888
|
if (opt.cliName === nameOrAlias) return true;
|
|
838
889
|
if (opt.alias?.includes(nameOrAlias)) return true;
|
|
839
890
|
if (nameOrAlias.length > 1) {
|
|
840
|
-
if (opt.cliName.includes("-") &&
|
|
841
|
-
if (opt.alias?.some((a) => a.includes("-") &&
|
|
891
|
+
if (opt.cliName.includes("-") && require_subcommand_router.toCamelCase(opt.cliName) === nameOrAlias) return true;
|
|
892
|
+
if (opt.alias?.some((a) => a.includes("-") && require_subcommand_router.toCamelCase(a) === nameOrAlias)) return true;
|
|
842
893
|
}
|
|
843
894
|
return false;
|
|
844
895
|
});
|
|
@@ -1057,12 +1108,12 @@ function detectInlinePrefix(currentWord) {
|
|
|
1057
1108
|
* Schema for the __complete command
|
|
1058
1109
|
*/
|
|
1059
1110
|
const completeArgsSchema = zod.z.object({
|
|
1060
|
-
shell:
|
|
1111
|
+
shell: require_subcommand_router.arg(zod.z.enum([
|
|
1061
1112
|
"bash",
|
|
1062
1113
|
"zsh",
|
|
1063
1114
|
"fish"
|
|
1064
1115
|
]), { description: "Target shell for output formatting" }),
|
|
1065
|
-
args:
|
|
1116
|
+
args: require_subcommand_router.arg(zod.z.array(zod.z.string()).default([]), {
|
|
1066
1117
|
positional: true,
|
|
1067
1118
|
description: "Arguments to complete",
|
|
1068
1119
|
variadic: true
|
|
@@ -1228,7 +1279,7 @@ function generateSubHandler$1(sub, fn, path) {
|
|
|
1228
1279
|
lines.push(...availableOptionLines$1(sub.options, fn));
|
|
1229
1280
|
lines.push(` return`);
|
|
1230
1281
|
lines.push(` end`);
|
|
1231
|
-
if (visibleSubs.length > 0) for (const s of
|
|
1282
|
+
if (visibleSubs.length > 0) for (const s of getSubNamesWithAliases(sub.subcommands)) {
|
|
1232
1283
|
const desc = escapeDesc$1(s.description ?? "");
|
|
1233
1284
|
lines.push(` echo "${s.name}\t${desc}"`);
|
|
1234
1285
|
}
|
|
@@ -1249,6 +1300,10 @@ function optTakesValueCases(sub, parentPath) {
|
|
|
1249
1300
|
for (const child of getVisibleSubs(sub.subcommands)) {
|
|
1250
1301
|
const childPath = parentPath ? `${parentPath}:${child.name}` : child.name;
|
|
1251
1302
|
lines.push(...optTakesValueCases(child, childPath));
|
|
1303
|
+
if (child.aliases) for (const alias of child.aliases) {
|
|
1304
|
+
const aliasPath = parentPath ? `${parentPath}:${alias}` : alias;
|
|
1305
|
+
lines.push(...optTakesValueCases(child, aliasPath));
|
|
1306
|
+
}
|
|
1252
1307
|
}
|
|
1253
1308
|
return lines;
|
|
1254
1309
|
}
|
|
@@ -1305,7 +1360,7 @@ function generateFishCompletion(command, options) {
|
|
|
1305
1360
|
lines.push(...availableOptionLines$1(root.options, fn));
|
|
1306
1361
|
if (visibleSubs.length > 0) {
|
|
1307
1362
|
lines.push(` else`);
|
|
1308
|
-
for (const s of
|
|
1363
|
+
for (const s of getSubNamesWithAliases(root.subcommands)) {
|
|
1309
1364
|
const desc = escapeDesc$1(s.description ?? "");
|
|
1310
1365
|
lines.push(` echo "${s.name}\t${desc}"`);
|
|
1311
1366
|
}
|
|
@@ -1493,7 +1548,7 @@ function generateSubHandler(sub, fn, path) {
|
|
|
1493
1548
|
lines.push(` return 0`);
|
|
1494
1549
|
lines.push(` fi`);
|
|
1495
1550
|
if (visibleSubs.length > 0) {
|
|
1496
|
-
const subItems =
|
|
1551
|
+
const subItems = getSubNamesWithAliases(sub.subcommands).map((s) => {
|
|
1497
1552
|
const desc = s.description ? `:${escapeDesc(s.description)}` : "";
|
|
1498
1553
|
return `"${s.name}${desc}"`;
|
|
1499
1554
|
}).join(" ");
|
|
@@ -1568,7 +1623,7 @@ function generateZshCompletion(command, options) {
|
|
|
1568
1623
|
lines.push(` __${fn}_cdescribe 'options' _opts`);
|
|
1569
1624
|
if (visibleSubs.length > 0) {
|
|
1570
1625
|
lines.push(` else`);
|
|
1571
|
-
const subItems =
|
|
1626
|
+
const subItems = getSubNamesWithAliases(root.subcommands).map((s) => {
|
|
1572
1627
|
const desc = s.description ? `:${escapeDesc(s.description)}` : "";
|
|
1573
1628
|
return `"${s.name}${desc}"`;
|
|
1574
1629
|
}).join(" ");
|
|
@@ -1697,7 +1752,7 @@ function detectShell() {
|
|
|
1697
1752
|
* Schema for the completion command arguments
|
|
1698
1753
|
*/
|
|
1699
1754
|
const completionArgsSchema = zod.z.object({
|
|
1700
|
-
shell:
|
|
1755
|
+
shell: require_subcommand_router.arg(zod.z.enum([
|
|
1701
1756
|
"bash",
|
|
1702
1757
|
"zsh",
|
|
1703
1758
|
"fish"
|
|
@@ -1706,7 +1761,7 @@ const completionArgsSchema = zod.z.object({
|
|
|
1706
1761
|
description: "Shell type (bash, zsh, or fish)",
|
|
1707
1762
|
placeholder: "SHELL"
|
|
1708
1763
|
}),
|
|
1709
|
-
instructions:
|
|
1764
|
+
instructions: require_subcommand_router.arg(zod.z.boolean().default(false), {
|
|
1710
1765
|
alias: "i",
|
|
1711
1766
|
description: "Show installation instructions"
|
|
1712
1767
|
})
|
|
@@ -1882,4 +1937,4 @@ Object.defineProperty(exports, 'withCompletionCommand', {
|
|
|
1882
1937
|
return withCompletionCommand;
|
|
1883
1938
|
}
|
|
1884
1939
|
});
|
|
1885
|
-
//# sourceMappingURL=completion-
|
|
1940
|
+
//# sourceMappingURL=completion-B5fgnUGm.cjs.map
|