politty 0.4.13 → 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-CeIRoLaB.d.cts → arg-registry-CB5gGtzp.d.cts} +55 -14
- package/dist/arg-registry-CB5gGtzp.d.cts.map +1 -0
- package/dist/{arg-registry-6E4C5MTC.d.ts → arg-registry-Dw0f11Zc.d.ts} +55 -14
- package/dist/arg-registry-Dw0f11Zc.d.ts.map +1 -0
- package/dist/augment.d.cts +3 -2
- package/dist/augment.d.cts.map +1 -1
- package/dist/augment.d.ts +3 -2
- package/dist/augment.d.ts.map +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-D3LUac1o.cjs → completion-B5fgnUGm.cjs} +103 -38
- package/dist/completion-B5fgnUGm.cjs.map +1 -0
- package/dist/{completion-DzaT2YCN.js → completion-Ca5ESJlG.js} +91 -26
- package/dist/completion-Ca5ESJlG.js.map +1 -0
- package/dist/docs/index.cjs +59 -50
- 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 +52 -43
- package/dist/docs/index.js.map +1 -1
- package/dist/{index-C3UtsvgY.d.ts → index-C1gGgUeB.d.cts} +9 -4
- package/dist/index-C1gGgUeB.d.cts.map +1 -0
- package/dist/{index-BW02tH1-.d.cts → index-Dg9Fpz0R.d.ts} +9 -4
- 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-BnHpqyRk.cjs → log-collector-Cd2_mv87.cjs} +1 -59
- package/dist/log-collector-Cd2_mv87.cjs.map +1 -0
- package/dist/{subcommand-router-BhYVuS83.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-DA48D-3K.cjs → runner-CriXJlm4.cjs} +176 -74
- package/dist/runner-CriXJlm4.cjs.map +1 -0
- package/dist/{runner-CnG-Ncz0.js → runner-DKAQBNNh.js} +149 -47
- package/dist/runner-DKAQBNNh.js.map +1 -0
- package/dist/{lazy-qPy4cMnv.cjs → subcommand-router-CqZX3orq.cjs} +140 -3
- package/dist/subcommand-router-CqZX3orq.cjs.map +1 -0
- package/dist/{lazy-xrzxwnru.js → subcommand-router-ENeCymvX.js} +104 -3
- package/dist/subcommand-router-ENeCymvX.js.map +1 -0
- package/package.json +12 -12
- package/dist/arg-registry-6E4C5MTC.d.ts.map +0 -1
- package/dist/arg-registry-CeIRoLaB.d.cts.map +0 -1
- package/dist/completion-D3LUac1o.cjs.map +0 -1
- package/dist/completion-DzaT2YCN.js.map +0 -1
- package/dist/index-BW02tH1-.d.cts.map +0 -1
- package/dist/index-C3UtsvgY.d.ts.map +0 -1
- package/dist/lazy-qPy4cMnv.cjs.map +0 -1
- package/dist/lazy-xrzxwnru.js.map +0 -1
- package/dist/runner-CnG-Ncz0.js.map +0 -1
- package/dist/runner-DA48D-3K.cjs.map +0 -1
- package/dist/subcommand-router-BhYVuS83.js.map +0 -1
- package/dist/subcommand-router-BnHpqyRk.cjs.map +0 -1
|
@@ -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)
|
|
@@ -192,16 +213,20 @@ function optTakesValueEntries(sub, parentPath) {
|
|
|
192
213
|
const lines = [];
|
|
193
214
|
for (const opt of sub.options) if (opt.takesValue) {
|
|
194
215
|
const patterns = [`${parentPath}:--${opt.cliName}`];
|
|
195
|
-
if (opt.alias) patterns.push(`${parentPath}
|
|
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 {
|
|
@@ -332,7 +366,7 @@ function optionValueCases$2(options, inline) {
|
|
|
332
366
|
const valLines = bashValueLines(opt.valueCompletion, inline);
|
|
333
367
|
if (valLines.length === 0) continue;
|
|
334
368
|
const patterns = [`--${opt.cliName}`];
|
|
335
|
-
if (opt.alias) patterns.push(`-${
|
|
369
|
+
if (opt.alias) for (const a of opt.alias) patterns.push(a.length === 1 ? `-${a}` : `--${a}`);
|
|
336
370
|
const patternStr = patterns.join("|");
|
|
337
371
|
lines.push(` ${patternStr})`);
|
|
338
372
|
for (const vl of valLines) lines.push(` ${vl}`);
|
|
@@ -382,7 +416,7 @@ function availableOptionLines$2(options, fn) {
|
|
|
382
416
|
for (const opt of options) if (opt.valueType === "array") lines.push(` _avail+=(--${opt.cliName})`);
|
|
383
417
|
else {
|
|
384
418
|
const patterns = [`"--${opt.cliName}"`];
|
|
385
|
-
if (opt.alias) patterns.push(`"-${
|
|
419
|
+
if (opt.alias) for (const a of opt.alias) patterns.push(a.length === 1 ? `"-${a}"` : `"--${a}"`);
|
|
386
420
|
lines.push(` __${fn}_not_used ${patterns.join(" ")} && _avail+=(--${opt.cliName})`);
|
|
387
421
|
}
|
|
388
422
|
lines.push(` __${fn}_not_used "--help" && _avail+=(--help)`);
|
|
@@ -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,
|
|
@@ -693,7 +735,9 @@ function generateOptionNameCandidates(context) {
|
|
|
693
735
|
const directive = CompletionDirective.FilterPrefix;
|
|
694
736
|
const availableOptions = context.options.filter((opt) => {
|
|
695
737
|
if (opt.valueType === "array") return true;
|
|
696
|
-
|
|
738
|
+
if (context.usedOptions.has(opt.cliName)) return false;
|
|
739
|
+
if (opt.alias && opt.alias.some((a) => context.usedOptions.has(a))) return false;
|
|
740
|
+
return true;
|
|
697
741
|
});
|
|
698
742
|
for (const opt of availableOptions) candidates.push({
|
|
699
743
|
value: `--${opt.cliName}`,
|
|
@@ -761,7 +805,7 @@ function generatePositionalCandidates(context) {
|
|
|
761
805
|
*/
|
|
762
806
|
function extractOptions(command) {
|
|
763
807
|
if (!command.args) return [];
|
|
764
|
-
return
|
|
808
|
+
return require_subcommand_router.extractFields(command.args).fields.filter((field) => !field.positional).map((field) => ({
|
|
765
809
|
name: field.name,
|
|
766
810
|
cliName: field.cliName,
|
|
767
811
|
alias: field.alias,
|
|
@@ -777,7 +821,7 @@ function extractOptions(command) {
|
|
|
777
821
|
*/
|
|
778
822
|
function extractPositionalsForContext(command) {
|
|
779
823
|
if (!command.args) return [];
|
|
780
|
-
return
|
|
824
|
+
return require_subcommand_router.extractFields(command.args).fields.filter((field) => field.positional).map((field, index) => ({
|
|
781
825
|
name: field.name,
|
|
782
826
|
cliName: field.cliName,
|
|
783
827
|
position: index,
|
|
@@ -788,20 +832,29 @@ function extractPositionalsForContext(command) {
|
|
|
788
832
|
}));
|
|
789
833
|
}
|
|
790
834
|
/**
|
|
791
|
-
* Get subcommand names from a command
|
|
835
|
+
* Get subcommand names from a command (including aliases)
|
|
792
836
|
*/
|
|
793
837
|
function getSubcommandNames(command) {
|
|
794
838
|
if (!command.subCommands) return [];
|
|
795
|
-
|
|
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;
|
|
796
847
|
}
|
|
797
848
|
/**
|
|
798
|
-
* Resolve subcommand by name
|
|
849
|
+
* Resolve subcommand by name (including alias lookup)
|
|
799
850
|
*/
|
|
800
851
|
function resolveSubcommand(command, name) {
|
|
801
852
|
if (!command.subCommands) return null;
|
|
802
853
|
const sub = command.subCommands[name];
|
|
803
|
-
if (
|
|
804
|
-
|
|
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;
|
|
805
858
|
}
|
|
806
859
|
/**
|
|
807
860
|
* Check if a word is an option (starts with - or --)
|
|
@@ -831,7 +884,15 @@ function hasInlineValue(word) {
|
|
|
831
884
|
* Find option by name or alias
|
|
832
885
|
*/
|
|
833
886
|
function findOption(options, nameOrAlias) {
|
|
834
|
-
return options.find((opt) =>
|
|
887
|
+
return options.find((opt) => {
|
|
888
|
+
if (opt.cliName === nameOrAlias) return true;
|
|
889
|
+
if (opt.alias?.includes(nameOrAlias)) return true;
|
|
890
|
+
if (nameOrAlias.length > 1) {
|
|
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;
|
|
893
|
+
}
|
|
894
|
+
return false;
|
|
895
|
+
});
|
|
835
896
|
}
|
|
836
897
|
/**
|
|
837
898
|
* Parse completion context from command line arguments
|
|
@@ -860,7 +921,7 @@ function parseCompletionContext(argv, rootCommand) {
|
|
|
860
921
|
const opt = findOption(options, optName);
|
|
861
922
|
if (opt) {
|
|
862
923
|
usedOptions.add(opt.cliName);
|
|
863
|
-
if (opt.alias)
|
|
924
|
+
if (opt.alias) for (const a of opt.alias) usedOptions.add(a);
|
|
864
925
|
if (opt.takesValue && !hasInlineValue(word)) i++;
|
|
865
926
|
}
|
|
866
927
|
i++;
|
|
@@ -1047,12 +1108,12 @@ function detectInlinePrefix(currentWord) {
|
|
|
1047
1108
|
* Schema for the __complete command
|
|
1048
1109
|
*/
|
|
1049
1110
|
const completeArgsSchema = zod.z.object({
|
|
1050
|
-
shell:
|
|
1111
|
+
shell: require_subcommand_router.arg(zod.z.enum([
|
|
1051
1112
|
"bash",
|
|
1052
1113
|
"zsh",
|
|
1053
1114
|
"fish"
|
|
1054
1115
|
]), { description: "Target shell for output formatting" }),
|
|
1055
|
-
args:
|
|
1116
|
+
args: require_subcommand_router.arg(zod.z.array(zod.z.string()).default([]), {
|
|
1056
1117
|
positional: true,
|
|
1057
1118
|
description: "Arguments to complete",
|
|
1058
1119
|
variadic: true
|
|
@@ -1150,7 +1211,7 @@ function optionValueCases$1(options) {
|
|
|
1150
1211
|
const valLines = fishValueLines(opt.valueCompletion);
|
|
1151
1212
|
if (valLines.length === 0) continue;
|
|
1152
1213
|
const conditions = [`test "$_prev" = "--${opt.cliName}"`];
|
|
1153
|
-
if (opt.alias) conditions.push(`test "$_prev" = "
|
|
1214
|
+
if (opt.alias) for (const a of opt.alias) conditions.push(`test "$_prev" = "${a.length === 1 ? `-${a}` : `--${a}`}"`);
|
|
1154
1215
|
const cond = conditions.join("; or ");
|
|
1155
1216
|
lines.push(` if ${cond}`);
|
|
1156
1217
|
for (const vl of valLines) lines.push(` ${vl}`);
|
|
@@ -1182,7 +1243,7 @@ function availableOptionLines$1(options, fn) {
|
|
|
1182
1243
|
if (opt.valueType === "array") lines.push(` echo "--${opt.cliName}\t${desc}"`);
|
|
1183
1244
|
else {
|
|
1184
1245
|
const checks = [`"--${opt.cliName}"`];
|
|
1185
|
-
if (opt.alias) checks.push(`"-${
|
|
1246
|
+
if (opt.alias) for (const a of opt.alias) checks.push(a.length === 1 ? `"-${a}"` : `"--${a}"`);
|
|
1186
1247
|
lines.push(` __${fn}_not_used ${checks.join(" ")}; and echo "--${opt.cliName}\t${desc}"`);
|
|
1187
1248
|
}
|
|
1188
1249
|
}
|
|
@@ -1218,7 +1279,7 @@ function generateSubHandler$1(sub, fn, path) {
|
|
|
1218
1279
|
lines.push(...availableOptionLines$1(sub.options, fn));
|
|
1219
1280
|
lines.push(` return`);
|
|
1220
1281
|
lines.push(` end`);
|
|
1221
|
-
if (visibleSubs.length > 0) for (const s of
|
|
1282
|
+
if (visibleSubs.length > 0) for (const s of getSubNamesWithAliases(sub.subcommands)) {
|
|
1222
1283
|
const desc = escapeDesc$1(s.description ?? "");
|
|
1223
1284
|
lines.push(` echo "${s.name}\t${desc}"`);
|
|
1224
1285
|
}
|
|
@@ -1232,13 +1293,17 @@ function optTakesValueCases(sub, parentPath) {
|
|
|
1232
1293
|
const lines = [];
|
|
1233
1294
|
for (const opt of sub.options) if (opt.takesValue) {
|
|
1234
1295
|
const patterns = [`"${parentPath}:--${opt.cliName}"`];
|
|
1235
|
-
if (opt.alias) patterns.push(`"${parentPath}
|
|
1296
|
+
if (opt.alias) for (const a of opt.alias) patterns.push(`"${parentPath}:${a.length === 1 ? `-${a}` : `--${a}`}"`);
|
|
1236
1297
|
lines.push(` case ${patterns.join(" ")}`);
|
|
1237
1298
|
lines.push(` return 0`);
|
|
1238
1299
|
}
|
|
1239
1300
|
for (const child of getVisibleSubs(sub.subcommands)) {
|
|
1240
1301
|
const childPath = parentPath ? `${parentPath}:${child.name}` : child.name;
|
|
1241
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
|
+
}
|
|
1242
1307
|
}
|
|
1243
1308
|
return lines;
|
|
1244
1309
|
}
|
|
@@ -1295,7 +1360,7 @@ function generateFishCompletion(command, options) {
|
|
|
1295
1360
|
lines.push(...availableOptionLines$1(root.options, fn));
|
|
1296
1361
|
if (visibleSubs.length > 0) {
|
|
1297
1362
|
lines.push(` else`);
|
|
1298
|
-
for (const s of
|
|
1363
|
+
for (const s of getSubNamesWithAliases(root.subcommands)) {
|
|
1299
1364
|
const desc = escapeDesc$1(s.description ?? "");
|
|
1300
1365
|
lines.push(` echo "${s.name}\t${desc}"`);
|
|
1301
1366
|
}
|
|
@@ -1407,7 +1472,7 @@ function optionValueCases(options, fn) {
|
|
|
1407
1472
|
const valLines = zshValueLines(opt.valueCompletion, fn);
|
|
1408
1473
|
if (valLines.length === 0) continue;
|
|
1409
1474
|
const patterns = [`--${opt.cliName}`];
|
|
1410
|
-
if (opt.alias) patterns.push(`-${
|
|
1475
|
+
if (opt.alias) for (const a of opt.alias) patterns.push(a.length === 1 ? `-${a}` : `--${a}`);
|
|
1411
1476
|
lines.push(` ${patterns.join("|")})`);
|
|
1412
1477
|
for (const vl of valLines) lines.push(` ${vl}`);
|
|
1413
1478
|
lines.push(` return 0 ;;`);
|
|
@@ -1448,7 +1513,7 @@ function availableOptionLines(options, fn) {
|
|
|
1448
1513
|
if (opt.valueType === "array") lines.push(` _opts+=("--${opt.cliName}${desc}")`);
|
|
1449
1514
|
else {
|
|
1450
1515
|
const patterns = [`"--${opt.cliName}"`];
|
|
1451
|
-
if (opt.alias) patterns.push(`"-${
|
|
1516
|
+
if (opt.alias) for (const a of opt.alias) patterns.push(a.length === 1 ? `"-${a}"` : `"--${a}"`);
|
|
1452
1517
|
lines.push(` __${fn}_not_used ${patterns.join(" ")} && _opts+=("--${opt.cliName}${desc}")`);
|
|
1453
1518
|
}
|
|
1454
1519
|
}
|
|
@@ -1483,7 +1548,7 @@ function generateSubHandler(sub, fn, path) {
|
|
|
1483
1548
|
lines.push(` return 0`);
|
|
1484
1549
|
lines.push(` fi`);
|
|
1485
1550
|
if (visibleSubs.length > 0) {
|
|
1486
|
-
const subItems =
|
|
1551
|
+
const subItems = getSubNamesWithAliases(sub.subcommands).map((s) => {
|
|
1487
1552
|
const desc = s.description ? `:${escapeDesc(s.description)}` : "";
|
|
1488
1553
|
return `"${s.name}${desc}"`;
|
|
1489
1554
|
}).join(" ");
|
|
@@ -1558,7 +1623,7 @@ function generateZshCompletion(command, options) {
|
|
|
1558
1623
|
lines.push(` __${fn}_cdescribe 'options' _opts`);
|
|
1559
1624
|
if (visibleSubs.length > 0) {
|
|
1560
1625
|
lines.push(` else`);
|
|
1561
|
-
const subItems =
|
|
1626
|
+
const subItems = getSubNamesWithAliases(root.subcommands).map((s) => {
|
|
1562
1627
|
const desc = s.description ? `:${escapeDesc(s.description)}` : "";
|
|
1563
1628
|
return `"${s.name}${desc}"`;
|
|
1564
1629
|
}).join(" ");
|
|
@@ -1687,7 +1752,7 @@ function detectShell() {
|
|
|
1687
1752
|
* Schema for the completion command arguments
|
|
1688
1753
|
*/
|
|
1689
1754
|
const completionArgsSchema = zod.z.object({
|
|
1690
|
-
shell:
|
|
1755
|
+
shell: require_subcommand_router.arg(zod.z.enum([
|
|
1691
1756
|
"bash",
|
|
1692
1757
|
"zsh",
|
|
1693
1758
|
"fish"
|
|
@@ -1696,7 +1761,7 @@ const completionArgsSchema = zod.z.object({
|
|
|
1696
1761
|
description: "Shell type (bash, zsh, or fish)",
|
|
1697
1762
|
placeholder: "SHELL"
|
|
1698
1763
|
}),
|
|
1699
|
-
instructions:
|
|
1764
|
+
instructions: require_subcommand_router.arg(zod.z.boolean().default(false), {
|
|
1700
1765
|
alias: "i",
|
|
1701
1766
|
description: "Show installation instructions"
|
|
1702
1767
|
})
|
|
@@ -1872,4 +1937,4 @@ Object.defineProperty(exports, 'withCompletionCommand', {
|
|
|
1872
1937
|
return withCompletionCommand;
|
|
1873
1938
|
}
|
|
1874
1939
|
});
|
|
1875
|
-
//# sourceMappingURL=completion-
|
|
1940
|
+
//# sourceMappingURL=completion-B5fgnUGm.cjs.map
|