@wolfstar/cli 2.2.0 → 2.3.0-next-20261004142621

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.
Files changed (90) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +465 -304
  3. package/dist/{_shared-DJrpalNQ.js → _shared-BIQK0Bhm.js} +2 -2
  4. package/dist/_shared-BIQK0Bhm.js.map +1 -0
  5. package/dist/bridge-BvkmlAOZ.js +410 -0
  6. package/dist/bridge-BvkmlAOZ.js.map +1 -0
  7. package/dist/{build-CluOR8dJ.js → build-DJcc95Yq.js} +5 -5
  8. package/dist/build-DJcc95Yq.js.map +1 -0
  9. package/dist/cli.js +1 -1
  10. package/dist/cli.js.map +1 -1
  11. package/dist/{codegen-D6V1i_fa.js → codegen-aJSyPz-J.js} +4 -4
  12. package/dist/codegen-aJSyPz-J.js.map +1 -0
  13. package/dist/command-diff-BK912Hjc.js +78 -0
  14. package/dist/command-diff-BK912Hjc.js.map +1 -0
  15. package/dist/commands-CIPWQtF0.js +3 -0
  16. package/dist/commands-Clpbqq3K.js +15 -0
  17. package/dist/commands-Clpbqq3K.js.map +1 -0
  18. package/dist/{commands-BJ589_AC.js → commands-DVC7ky6f.js} +259 -9
  19. package/dist/commands-DVC7ky6f.js.map +1 -0
  20. package/dist/completions-D2KYtrrv.js +161 -0
  21. package/dist/completions-D2KYtrrv.js.map +1 -0
  22. package/dist/{dev-DJJZN4NJ.js → dev-oPPVR7d_.js} +434 -28
  23. package/dist/dev-oPPVR7d_.js.map +1 -0
  24. package/dist/{diagnostics-3JRAy8Xj.js → diagnostics-BysbNnPD.js} +22 -1
  25. package/dist/diagnostics-BysbNnPD.js.map +1 -0
  26. package/dist/doctor-DkVUwgDd.js +334 -0
  27. package/dist/doctor-DkVUwgDd.js.map +1 -0
  28. package/dist/errors-COFWKKKw.js.map +1 -1
  29. package/dist/external-CxFKxwi3.js.map +1 -1
  30. package/dist/framework-auto-imports-Gu_PXSyr.js.map +1 -1
  31. package/dist/{hooks-BfDFM38k.js → hooks-Cy6F2bhH.js} +20 -4
  32. package/dist/hooks-Cy6F2bhH.js.map +1 -0
  33. package/dist/index.d.ts +53 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +3 -3
  36. package/dist/{info-C1Kx_4Og.js → info-CKJVMWIT.js} +15 -4
  37. package/dist/info-CKJVMWIT.js.map +1 -0
  38. package/dist/{locales-BzOLRBVg.js → locales-BJAP4HYf.js} +5 -5
  39. package/dist/locales-BJAP4HYf.js.map +1 -0
  40. package/dist/log-view-B7uJEnMR.js +342 -0
  41. package/dist/log-view-B7uJEnMR.js.map +1 -0
  42. package/dist/{nitro-yjqZBh5L.js → nitro-B8u1iVgf.js} +2 -2
  43. package/dist/nitro-B8u1iVgf.js.map +1 -0
  44. package/dist/none-uC_wi_l4.js.map +1 -1
  45. package/dist/output-mode-Bp7Da8vJ.js.map +1 -1
  46. package/dist/{plain-B6z85uQP.js → plain-DG7cy0Kk.js} +7 -2
  47. package/dist/plain-DG7cy0Kk.js.map +1 -0
  48. package/dist/{prepare-Cb45Z4re.js → prepare-BM93i3Rm.js} +4 -4
  49. package/dist/prepare-BM93i3Rm.js.map +1 -0
  50. package/dist/{project-D-8VIcyF.js → project-zlQStwsf.js} +2 -2
  51. package/dist/project-zlQStwsf.js.map +1 -0
  52. package/dist/{run-BiLZqib3.js → run-DMM2YlP3.js} +2 -12
  53. package/dist/run-DMM2YlP3.js.map +1 -0
  54. package/dist/{theme-3Fc_LI-2.js → theme-yS2h5dd_.js} +25 -1
  55. package/dist/theme-yS2h5dd_.js.map +1 -0
  56. package/dist/tsc-C5l5TQGC.js +3 -0
  57. package/dist/{tsc-DEBcwIO0.js → tsc-puVAcwmo.js} +24 -5
  58. package/dist/tsc-puVAcwmo.js.map +1 -0
  59. package/dist/{tsdown-DrWXld54.js → tsdown-Dwt3JhPw.js} +2 -2
  60. package/dist/tsdown-Dwt3JhPw.js.map +1 -0
  61. package/dist/{tui-BRddrLQP.js → tui-nldGSD4c.js} +913 -141
  62. package/dist/tui-nldGSD4c.js.map +1 -0
  63. package/dist/version-BzclCE19.js.map +1 -1
  64. package/dist/{vite-Bf7nrJx7.js → vite-YZUtv2Hk.js} +2 -2
  65. package/dist/vite-YZUtv2Hk.js.map +1 -0
  66. package/package.json +5 -5
  67. package/dist/_shared-DJrpalNQ.js.map +0 -1
  68. package/dist/build-CluOR8dJ.js.map +0 -1
  69. package/dist/codegen-D6V1i_fa.js.map +0 -1
  70. package/dist/commands-BJ589_AC.js.map +0 -1
  71. package/dist/dev-DJJZN4NJ.js.map +0 -1
  72. package/dist/diagnostics-3JRAy8Xj.js.map +0 -1
  73. package/dist/hooks-BfDFM38k.js.map +0 -1
  74. package/dist/info-C1Kx_4Og.js.map +0 -1
  75. package/dist/locales-BzOLRBVg.js.map +0 -1
  76. package/dist/log-buffer-CY82aqnb.js +0 -72
  77. package/dist/log-buffer-CY82aqnb.js.map +0 -1
  78. package/dist/nitro-yjqZBh5L.js.map +0 -1
  79. package/dist/plain-B6z85uQP.js.map +0 -1
  80. package/dist/prepare-Cb45Z4re.js.map +0 -1
  81. package/dist/project-D-8VIcyF.js.map +0 -1
  82. package/dist/run-BiLZqib3.js.map +0 -1
  83. package/dist/theme-3Fc_LI-2.js.map +0 -1
  84. package/dist/tsc-B931Ezh7.js +0 -3
  85. package/dist/tsc-DEBcwIO0.js.map +0 -1
  86. package/dist/tsdown-DrWXld54.js.map +0 -1
  87. package/dist/tui-BRddrLQP.js.map +0 -1
  88. package/dist/tunnel-DHSxOZKr.js +0 -175
  89. package/dist/tunnel-DHSxOZKr.js.map +0 -1
  90. package/dist/vite-Bf7nrJx7.js.map +0 -1
@@ -0,0 +1,161 @@
1
+ import { t as cliDiagnostics } from "./diagnostics-BysbNnPD.js";
2
+ import { defineCommand } from "citty";
3
+
4
+ //#region src/commands/completions.ts
5
+ const SHELLS = [
6
+ "bash",
7
+ "zsh",
8
+ "fish"
9
+ ];
10
+ async function resolve(value) {
11
+ return typeof value === "function" ? value() : value;
12
+ }
13
+ /** Walks the commands the CLI registers, so the completions never drift from what `--help` prints. */
14
+ async function describeCommands(commands) {
15
+ const describe = async (name, command) => {
16
+ const meta = await resolve(command.meta) ?? {};
17
+ const args = await resolve(command.args) ?? {};
18
+ const children = await resolve(command.subCommands) ?? {};
19
+ return {
20
+ name,
21
+ description: meta.description ?? "",
22
+ flags: Object.entries(args).filter(([, arg]) => arg.type !== "positional").map(([flag, arg]) => ({
23
+ name: flag,
24
+ description: arg.description ?? "",
25
+ aliases: [arg.alias ?? []].flat(),
26
+ negatable: arg.type === "boolean" && arg.default === true
27
+ })),
28
+ subcommands: await Promise.all(Object.entries(children).map(async ([child, value]) => describe(child, await resolve(value))))
29
+ };
30
+ };
31
+ return Promise.all(Object.entries(commands).map(async ([name, load]) => describe(name, await load())));
32
+ }
33
+ /** Every spelling of a flag: `--name`, `--no-name` when it can be switched off, and its short forms. */
34
+ const spellings = (flag) => [
35
+ `--${flag.name}`,
36
+ ...flag.negatable ? [`--no-${flag.name}`] : [],
37
+ ...flag.aliases.map((alias) => alias.length === 1 ? `-${alias}` : `--${alias}`)
38
+ ];
39
+ const flagsOf = (command) => [...command.flags.flatMap(spellings), "--help"].join(" ");
40
+ function bash(commands) {
41
+ const cases = commands.map((command) => {
42
+ if (command.subcommands.length === 0) return `\t\t${command.name}) words="${flagsOf(command)}" ;;`;
43
+ const nested = command.subcommands.map((child) => `\t\t\t\t${child.name}) words="${flagsOf(child)}" ;;`).join("\n");
44
+ return [
45
+ `\t\t${command.name})`,
46
+ " sub=\"\"",
47
+ " for ((i = 2; i < COMP_CWORD; i++)); do",
48
+ `\t\t\t\tcase "\${COMP_WORDS[i]}" in ${command.subcommands.map((child) => child.name).join("|")}) sub="\${COMP_WORDS[i]}"; break ;; esac`,
49
+ " done",
50
+ " case \"$sub\" in",
51
+ nested,
52
+ `\t\t\t\t*) words="${command.subcommands.map((child) => child.name).join(" ")} ${flagsOf(command)}" ;;`,
53
+ " esac ;;"
54
+ ].join("\n");
55
+ });
56
+ return `# stars completions for bash. Load them with: eval "$(stars completions bash)"
57
+ _stars() {
58
+ local cur words sub i
59
+ cur="\${COMP_WORDS[COMP_CWORD]}"
60
+ if [ "$COMP_CWORD" -eq 1 ]; then
61
+ words="${commands.map((command) => command.name).join(" ")} --help --version"
62
+ else
63
+ case "\${COMP_WORDS[1]}" in
64
+ ${cases.join("\n")}
65
+ *) words="" ;;
66
+ esac
67
+ fi
68
+ COMPREPLY=($(compgen -W "$words" -- "$cur"))
69
+ }
70
+ complete -o default -F _stars stars
71
+ `;
72
+ }
73
+ const quote = (text) => `'${text.replaceAll("'", "'\\''")}'`;
74
+ /** A zsh `_describe` entry: the colon separates the value from its description, so one in the text is escaped. */
75
+ const described = (name, description) => quote(`${name}:${description.replaceAll(":", "\\:")}`);
76
+ function zsh(commands) {
77
+ const flags = (command) => [...command.flags.flatMap((flag) => spellings(flag).map((spelling) => described(spelling, flag.description))), described("--help", "Show the usage")].join(" ");
78
+ const cases = commands.map((command) => {
79
+ if (command.subcommands.length === 0) return `\t\t${command.name}) items=(${flags(command)}) ;;`;
80
+ const nested = command.subcommands.map((child) => `\t\t\t\t${child.name}) items=(${flags(child)}) ;;`).join("\n");
81
+ const children = command.subcommands.map((child) => described(child.name, child.description)).join(" ");
82
+ return [
83
+ `\t\t${command.name})`,
84
+ " sub=\"\"",
85
+ " for word in ${words[3,CURRENT-1]}; do",
86
+ `\t\t\t\tcase "$word" in ${command.subcommands.map((child) => child.name).join("|")}) sub="$word"; break ;; esac`,
87
+ " done",
88
+ " case \"$sub\" in",
89
+ nested,
90
+ `\t\t\t\t*) items=(${children} ${flags(command)}) ;;`,
91
+ " esac ;;"
92
+ ].join("\n");
93
+ });
94
+ return `#compdef stars
95
+ # stars completions for zsh. Load them with: eval "$(stars completions zsh)"
96
+ _stars() {
97
+ local -a items
98
+ local sub word
99
+ if (( CURRENT == 2 )); then
100
+ items=(${commands.map((command) => described(command.name, command.description)).join(" ")})
101
+ else
102
+ case "$words[2]" in
103
+ ${cases.join("\n")}
104
+ esac
105
+ fi
106
+ _describe 'stars' items
107
+ }
108
+ compdef _stars stars
109
+ `;
110
+ }
111
+ function fishFlag(condition, flag) {
112
+ const short = flag.aliases.filter((alias) => alias.length === 1).map((alias) => ` -s ${alias}`).join("");
113
+ const line = (name) => `complete -c stars -n "${condition}" -l ${name}${name === flag.name ? short : ""} -d ${quote(flag.description)}`;
114
+ return [line(flag.name), ...flag.negatable ? [line(`no-${flag.name}`)] : []];
115
+ }
116
+ function fish(commands) {
117
+ const lines = ["# stars completions for fish. Load them with: stars completions fish | source", "complete -c stars -f"];
118
+ const names = commands.map((command) => command.name).join(" ");
119
+ for (const command of commands) {
120
+ lines.push(`complete -c stars -n "not __fish_seen_subcommand_from ${names}" -a ${command.name} -d ${quote(command.description)}`);
121
+ const children = command.subcommands.map((child) => child.name).join(" ");
122
+ for (const flag of command.flags) lines.push(...fishFlag(`__fish_seen_subcommand_from ${command.name}`, flag));
123
+ for (const child of command.subcommands) {
124
+ lines.push(`complete -c stars -n "__fish_seen_subcommand_from ${command.name}; and not __fish_seen_subcommand_from ${children}" -a ${child.name} -d ${quote(child.description)}`);
125
+ for (const flag of child.flags.filter((candidate) => !command.flags.some((own) => own.name === candidate.name))) lines.push(...fishFlag(`__fish_seen_subcommand_from ${command.name}; and __fish_seen_subcommand_from ${child.name}`, flag));
126
+ }
127
+ }
128
+ return `${lines.join("\n")}\n`;
129
+ }
130
+ const GENERATORS = {
131
+ bash,
132
+ zsh,
133
+ fish
134
+ };
135
+ /** The completion script of a shell, for the given commands. */
136
+ function generateCompletions(shell, commands) {
137
+ if (!SHELLS.includes(shell)) throw cliDiagnostics.UNKNOWN_SHELL({ shell });
138
+ return GENERATORS[shell](commands);
139
+ }
140
+ async function runCompletions(options) {
141
+ const { commands } = await import("./commands-CIPWQtF0.js");
142
+ (options.stdout ?? process.stdout).write(generateCompletions(options.shell, await describeCommands(commands)));
143
+ }
144
+ var completions_default = defineCommand({
145
+ meta: {
146
+ name: "completions",
147
+ description: "Print the shell completion script for bash, zsh or fish"
148
+ },
149
+ args: { shell: {
150
+ type: "positional",
151
+ description: `The shell to print completions for: ${SHELLS.join(", ")}`,
152
+ required: true
153
+ } },
154
+ async run({ args }) {
155
+ await runCompletions({ shell: args.shell });
156
+ }
157
+ });
158
+
159
+ //#endregion
160
+ export { completions_default as default };
161
+ //# sourceMappingURL=completions-D2KYtrrv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completions-D2KYtrrv.js","names":[],"sources":["../src/commands/completions.ts"],"sourcesContent":["import { defineCommand, type ArgsDef, type CommandDef } from 'citty';\nimport { cliDiagnostics } from '../utils/diagnostics.js';\n\n// citty types each command by its own arguments; the tree only needs the erased form.\n// oxlint-disable-next-line typescript/no-explicit-any\ntype AnyCommand = CommandDef<any>;\n\nexport interface CompletionFlag {\n\tname: string;\n\tdescription: string;\n\t/** Short forms, without the dash (`c` for `-c`). */\n\taliases: string[];\n\t/** A boolean that is on by default also has a `--no-<name>` form. */\n\tnegatable: boolean;\n}\n\nexport interface CompletionCommand {\n\tname: string;\n\tdescription: string;\n\tflags: CompletionFlag[];\n\tsubcommands: CompletionCommand[];\n}\n\nexport const SHELLS = ['bash', 'zsh', 'fish'] as const;\nexport type Shell = (typeof SHELLS)[number];\n\nasync function resolve<T>(value: T | Promise<T> | (() => T | Promise<T>) | undefined): Promise<T | undefined> {\n\treturn typeof value === 'function' ? (value as () => T | Promise<T>)() : value;\n}\n\n/** Walks the commands the CLI registers, so the completions never drift from what `--help` prints. */\nexport async function describeCommands(commands: Record<string, () => Promise<AnyCommand>>): Promise<CompletionCommand[]> {\n\tconst describe = async (name: string, command: AnyCommand): Promise<CompletionCommand> => {\n\t\tconst meta = (await resolve(command.meta)) ?? {};\n\t\tconst args = ((await resolve(command.args)) ?? {}) as ArgsDef;\n\t\tconst children = ((await resolve(command.subCommands)) ?? {}) as Record<string, AnyCommand | (() => Promise<AnyCommand>)>;\n\t\treturn {\n\t\t\tname,\n\t\t\tdescription: meta.description ?? '',\n\t\t\tflags: Object.entries(args)\n\t\t\t\t.filter(([, arg]) => arg.type !== 'positional')\n\t\t\t\t.map(([flag, arg]) => ({\n\t\t\t\t\tname: flag,\n\t\t\t\t\tdescription: arg.description ?? '',\n\t\t\t\t\taliases: [(arg as { alias?: string | string[] }).alias ?? []].flat(),\n\t\t\t\t\tnegatable: arg.type === 'boolean' && arg.default === true\n\t\t\t\t})),\n\t\t\tsubcommands: await Promise.all(Object.entries(children).map(async ([child, value]) => describe(child, (await resolve(value))!)))\n\t\t};\n\t};\n\n\treturn Promise.all(Object.entries(commands).map(async ([name, load]) => describe(name, await load())));\n}\n\n/** Every spelling of a flag: `--name`, `--no-name` when it can be switched off, and its short forms. */\nconst spellings = (flag: CompletionFlag) => [\n\t`--${flag.name}`,\n\t...(flag.negatable ? [`--no-${flag.name}`] : []),\n\t...flag.aliases.map((alias) => (alias.length === 1 ? `-${alias}` : `--${alias}`))\n];\n\nconst flagsOf = (command: CompletionCommand) => [...command.flags.flatMap(spellings), '--help'].join(' ');\n\nfunction bash(commands: readonly CompletionCommand[]): string {\n\tconst cases = commands.map((command) => {\n\t\tif (command.subcommands.length === 0) return `\\t\\t${command.name}) words=\"${flagsOf(command)}\" ;;`;\n\t\tconst nested = command.subcommands.map((child) => `\\t\\t\\t\\t${child.name}) words=\"${flagsOf(child)}\" ;;`).join('\\n');\n\t\treturn [\n\t\t\t`\\t\\t${command.name})`,\n\t\t\t// The subcommand is the first of its names after the command: options of the parent may come before it.\n\t\t\t'\\t\\t\\tsub=\"\"',\n\t\t\t'\\t\\t\\tfor ((i = 2; i < COMP_CWORD; i++)); do',\n\t\t\t`\\t\\t\\t\\tcase \"\\${COMP_WORDS[i]}\" in ${command.subcommands.map((child) => child.name).join('|')}) sub=\"\\${COMP_WORDS[i]}\"; break ;; esac`,\n\t\t\t'\\t\\t\\tdone',\n\t\t\t'\\t\\t\\tcase \"$sub\" in',\n\t\t\tnested,\n\t\t\t`\\t\\t\\t\\t*) words=\"${command.subcommands.map((child) => child.name).join(' ')} ${flagsOf(command)}\" ;;`,\n\t\t\t'\\t\\t\\tesac ;;'\n\t\t].join('\\n');\n\t});\n\n\treturn `# stars completions for bash. Load them with: eval \"$(stars completions bash)\"\n_stars() {\n\tlocal cur words sub i\n\tcur=\"\\${COMP_WORDS[COMP_CWORD]}\"\n\tif [ \"$COMP_CWORD\" -eq 1 ]; then\n\t\twords=\"${commands.map((command) => command.name).join(' ')} --help --version\"\n\telse\n\t\tcase \"\\${COMP_WORDS[1]}\" in\n${cases.join('\\n')}\n\t\t\t*) words=\"\" ;;\n\t\tesac\n\tfi\n\tCOMPREPLY=($(compgen -W \"$words\" -- \"$cur\"))\n}\ncomplete -o default -F _stars stars\n`;\n}\n\nconst quote = (text: string) => `'${text.replaceAll(\"'\", \"'\\\\''\")}'`;\n/** A zsh `_describe` entry: the colon separates the value from its description, so one in the text is escaped. */\nconst described = (name: string, description: string) => quote(`${name}:${description.replaceAll(':', '\\\\:')}`);\n\nfunction zsh(commands: readonly CompletionCommand[]): string {\n\tconst flags = (command: CompletionCommand) =>\n\t\t[\n\t\t\t...command.flags.flatMap((flag) => spellings(flag).map((spelling) => described(spelling, flag.description))),\n\t\t\tdescribed('--help', 'Show the usage')\n\t\t].join(' ');\n\tconst cases = commands.map((command) => {\n\t\tif (command.subcommands.length === 0) return `\\t\\t${command.name}) items=(${flags(command)}) ;;`;\n\t\tconst nested = command.subcommands.map((child) => `\\t\\t\\t\\t${child.name}) items=(${flags(child)}) ;;`).join('\\n');\n\t\tconst children = command.subcommands.map((child) => described(child.name, child.description)).join(' ');\n\t\treturn [\n\t\t\t`\\t\\t${command.name})`,\n\t\t\t'\\t\\t\\tsub=\"\"',\n\t\t\t'\\t\\t\\tfor word in ${words[3,CURRENT-1]}; do',\n\t\t\t`\\t\\t\\t\\tcase \"$word\" in ${command.subcommands.map((child) => child.name).join('|')}) sub=\"$word\"; break ;; esac`,\n\t\t\t'\\t\\t\\tdone',\n\t\t\t'\\t\\t\\tcase \"$sub\" in',\n\t\t\tnested,\n\t\t\t`\\t\\t\\t\\t*) items=(${children} ${flags(command)}) ;;`,\n\t\t\t'\\t\\t\\tesac ;;'\n\t\t].join('\\n');\n\t});\n\n\treturn `#compdef stars\n# stars completions for zsh. Load them with: eval \"$(stars completions zsh)\"\n_stars() {\n\tlocal -a items\n\tlocal sub word\n\tif (( CURRENT == 2 )); then\n\t\titems=(${commands.map((command) => described(command.name, command.description)).join(' ')})\n\telse\n\t\tcase \"$words[2]\" in\n${cases.join('\\n')}\n\t\tesac\n\tfi\n\t_describe 'stars' items\n}\ncompdef _stars stars\n`;\n}\n\nfunction fishFlag(condition: string, flag: CompletionFlag): string[] {\n\tconst short = flag.aliases\n\t\t.filter((alias) => alias.length === 1)\n\t\t.map((alias) => ` -s ${alias}`)\n\t\t.join('');\n\tconst line = (name: string) => `complete -c stars -n \"${condition}\" -l ${name}${name === flag.name ? short : ''} -d ${quote(flag.description)}`;\n\treturn [line(flag.name), ...(flag.negatable ? [line(`no-${flag.name}`)] : [])];\n}\n\nfunction fish(commands: readonly CompletionCommand[]): string {\n\tconst lines = ['# stars completions for fish. Load them with: stars completions fish | source', 'complete -c stars -f'];\n\tconst names = commands.map((command) => command.name).join(' ');\n\tfor (const command of commands) {\n\t\tlines.push(`complete -c stars -n \"not __fish_seen_subcommand_from ${names}\" -a ${command.name} -d ${quote(command.description)}`);\n\t\tconst children = command.subcommands.map((child) => child.name).join(' ');\n\t\tfor (const flag of command.flags) lines.push(...fishFlag(`__fish_seen_subcommand_from ${command.name}`, flag));\n\n\t\tfor (const child of command.subcommands) {\n\t\t\tlines.push(\n\t\t\t\t`complete -c stars -n \"__fish_seen_subcommand_from ${command.name}; and not __fish_seen_subcommand_from ${children}\" -a ${child.name} -d ${quote(child.description)}`\n\t\t\t);\n\t\t\tfor (const flag of child.flags.filter((candidate) => !command.flags.some((own) => own.name === candidate.name))) {\n\t\t\t\tlines.push(...fishFlag(`__fish_seen_subcommand_from ${command.name}; and __fish_seen_subcommand_from ${child.name}`, flag));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn `${lines.join('\\n')}\\n`;\n}\n\nconst GENERATORS: Record<Shell, (commands: readonly CompletionCommand[]) => string> = { bash, zsh, fish };\n\n/** The completion script of a shell, for the given commands. */\nexport function generateCompletions(shell: string, commands: readonly CompletionCommand[]): string {\n\tif (!(SHELLS as readonly string[]).includes(shell)) throw cliDiagnostics.UNKNOWN_SHELL({ shell });\n\treturn GENERATORS[shell as Shell](commands);\n}\n\nexport interface CompletionsOptions {\n\tshell: string;\n\tstdout?: NodeJS.WritableStream;\n}\n\nexport async function runCompletions(options: CompletionsOptions): Promise<void> {\n\t// Imported here: the registry imports this module, as it does every command.\n\tconst { commands } = await import('./index.js');\n\t(options.stdout ?? process.stdout).write(generateCompletions(options.shell, await describeCommands(commands)));\n}\n\nexport default defineCommand({\n\tmeta: {\n\t\tname: 'completions',\n\t\tdescription: 'Print the shell completion script for bash, zsh or fish'\n\t},\n\targs: {\n\t\tshell: {\n\t\t\ttype: 'positional',\n\t\t\tdescription: `The shell to print completions for: ${SHELLS.join(', ')}`,\n\t\t\trequired: true\n\t\t}\n\t},\n\tasync run({ args }) {\n\t\tawait runCompletions({ shell: args.shell });\n\t}\n});\n"],"mappings":";;;;AAuBA,MAAa,SAAS;CAAC;CAAQ;CAAO;AAAM;AAG5C,eAAe,QAAW,OAAoF;CAC7G,OAAO,OAAO,UAAU,aAAc,MAA+B,IAAI;AAC1E;;AAGA,eAAsB,iBAAiB,UAAmF;CACzH,MAAM,WAAW,OAAO,MAAc,YAAoD;EACzF,MAAM,OAAQ,MAAM,QAAQ,QAAQ,IAAI,KAAM,CAAC;EAC/C,MAAM,OAAS,MAAM,QAAQ,QAAQ,IAAI,KAAM,CAAC;EAChD,MAAM,WAAa,MAAM,QAAQ,QAAQ,WAAW,KAAM,CAAC;EAC3D,OAAO;GACN;GACA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