varlock 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audit.command-PXY2ZGU2.js +16 -0
- package/dist/{audit.command-6TUJY57M.js.map → audit.command-PXY2ZGU2.js.map} +1 -1
- package/dist/auto-load.js +5 -5
- package/dist/{chunk-CWC3IAQM.js → chunk-2GZ4APXU.js} +29 -14
- package/dist/chunk-2GZ4APXU.js.map +1 -0
- package/dist/{chunk-2OIOYMYO.js → chunk-66VKZYD7.js} +6 -6
- package/dist/{chunk-2OIOYMYO.js.map → chunk-66VKZYD7.js.map} +1 -1
- package/dist/{chunk-BR3DT5Z5.js → chunk-7VERU3F7.js} +3 -3
- package/dist/{chunk-BR3DT5Z5.js.map → chunk-7VERU3F7.js.map} +1 -1
- package/dist/{chunk-KCUEK4TX.js → chunk-A5L3SRQS.js} +7 -7
- package/dist/{chunk-KCUEK4TX.js.map → chunk-A5L3SRQS.js.map} +1 -1
- package/dist/{chunk-5DUWGI2N.js → chunk-DIPEXEIL.js} +3 -3
- package/dist/{chunk-5DUWGI2N.js.map → chunk-DIPEXEIL.js.map} +1 -1
- package/dist/{chunk-2NQLWXPX.js → chunk-DQTUCLA7.js} +5 -5
- package/dist/{chunk-2NQLWXPX.js.map → chunk-DQTUCLA7.js.map} +1 -1
- package/dist/{chunk-VIUMRSUR.js → chunk-EGFAEO7L.js} +8 -8
- package/dist/{chunk-VIUMRSUR.js.map → chunk-EGFAEO7L.js.map} +1 -1
- package/dist/{chunk-FCSQRLIC.js → chunk-F64DA7XN.js} +6 -6
- package/dist/{chunk-FCSQRLIC.js.map → chunk-F64DA7XN.js.map} +1 -1
- package/dist/{chunk-6CCHLM3U.js → chunk-FA5SNEKN.js} +30 -12
- package/dist/chunk-FA5SNEKN.js.map +1 -0
- package/dist/{chunk-F6RTQ5QX.js → chunk-KFALDUEO.js} +3 -3
- package/dist/{chunk-F6RTQ5QX.js.map → chunk-KFALDUEO.js.map} +1 -1
- package/dist/{chunk-OA6PRICO.js → chunk-M6QE3D2O.js} +6 -6
- package/dist/{chunk-OA6PRICO.js.map → chunk-M6QE3D2O.js.map} +1 -1
- package/dist/{chunk-4A54P4EM.js → chunk-MGUGRIW2.js} +1185 -1152
- package/dist/chunk-MGUGRIW2.js.map +1 -0
- package/dist/{chunk-26E4E2MY.js → chunk-N7FJTNE5.js} +11 -5
- package/dist/chunk-N7FJTNE5.js.map +1 -0
- package/dist/chunk-NHNQJTPB.js +171 -0
- package/dist/chunk-NHNQJTPB.js.map +1 -0
- package/dist/{chunk-6PZXN47A.js → chunk-NZTQKZND.js} +4 -4
- package/dist/{chunk-6PZXN47A.js.map → chunk-NZTQKZND.js.map} +1 -1
- package/dist/{chunk-GURKQO4J.js → chunk-P4HNABAM.js} +103 -20
- package/dist/chunk-P4HNABAM.js.map +1 -0
- package/dist/{chunk-6CRDPEUT.js → chunk-PBWMMYWL.js} +685 -684
- package/dist/chunk-PBWMMYWL.js.map +1 -0
- package/dist/{chunk-H2JVYUHZ.js → chunk-Q4I7MXFB.js} +6 -6
- package/dist/{chunk-H2JVYUHZ.js.map → chunk-Q4I7MXFB.js.map} +1 -1
- package/dist/{chunk-GJ7PTJM4.js → chunk-Q7XUQDLE.js} +3 -3
- package/dist/{chunk-GJ7PTJM4.js.map → chunk-Q7XUQDLE.js.map} +1 -1
- package/dist/{chunk-R73FENLU.js → chunk-QDEAHBCB.js} +3 -3
- package/dist/{chunk-R73FENLU.js.map → chunk-QDEAHBCB.js.map} +1 -1
- package/dist/{chunk-2PBFWISH.js → chunk-ROZITJAP.js} +8 -8
- package/dist/chunk-ROZITJAP.js.map +1 -0
- package/dist/{chunk-35LTPRXV.js → chunk-RTKFINP6.js} +6 -6
- package/dist/{chunk-35LTPRXV.js.map → chunk-RTKFINP6.js.map} +1 -1
- package/dist/{chunk-QSYH5IDD.js → chunk-RWXFFQWH.js} +4 -4
- package/dist/{chunk-QSYH5IDD.js.map → chunk-RWXFFQWH.js.map} +1 -1
- package/dist/{chunk-LGEHJHB2.js → chunk-SX2NUZCL.js} +6 -5
- package/dist/{chunk-LGEHJHB2.js.map → chunk-SX2NUZCL.js.map} +1 -1
- package/dist/{chunk-A2JUQ2GK.js → chunk-T3NMDBCU.js} +6 -6
- package/dist/{chunk-A2JUQ2GK.js.map → chunk-T3NMDBCU.js.map} +1 -1
- package/dist/{chunk-MGWUDHT5.js → chunk-UUJK65RS.js} +11 -3
- package/dist/chunk-UUJK65RS.js.map +1 -0
- package/dist/{chunk-YHN6GZHR.js → chunk-YZCCCHDD.js} +6 -6
- package/dist/{chunk-YHN6GZHR.js.map → chunk-YZCCCHDD.js.map} +1 -1
- package/dist/{chunk-EE4UNY25.js → chunk-ZCYV47TZ.js} +8 -8
- package/dist/{chunk-EE4UNY25.js.map → chunk-ZCYV47TZ.js.map} +1 -1
- package/dist/cli/cli-executable.js +1547 -40
- package/dist/cli/cli-executable.js.map +1 -1
- package/dist/config-item-HMRJLPJY.js +7 -0
- package/dist/{config-item-7X6PUXJF.js.map → config-item-HMRJLPJY.js.map} +1 -1
- package/dist/dotenv-compat.js +5 -5
- package/dist/encrypt.command-7M34IUJY.js +14 -0
- package/dist/{encrypt.command-4E5SM5M6.js.map → encrypt.command-7M34IUJY.js.map} +1 -1
- package/dist/{env-graph-iNQyTcya.d.ts → env-graph-DImkUkjl.d.ts} +30 -19
- package/dist/explain.command-LZJOP4TM.js +15 -0
- package/dist/{explain.command-7FRFYSJJ.js.map → explain.command-LZJOP4TM.js.map} +1 -1
- package/dist/help.command-VIBYZWCF.js +5 -0
- package/dist/{help.command-7E52XAOO.js.map → help.command-VIBYZWCF.js.map} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +13 -14
- package/dist/index.js.map +1 -1
- package/dist/init.command-FFORG2JL.js +14 -0
- package/dist/{init.command-EMPZK5D3.js.map → init.command-FFORG2JL.js.map} +1 -1
- package/dist/install-plugin.command-SFNHDKVE.js +13 -0
- package/dist/{install-plugin.command-SYQAPBII.js.map → install-plugin.command-SFNHDKVE.js.map} +1 -1
- package/dist/load.command-V3C5H6CZ.js +15 -0
- package/dist/{load.command-R7UTXX2X.js.map → load.command-V3C5H6CZ.js.map} +1 -1
- package/dist/lock.command-QQV2S6NY.js +7 -0
- package/dist/{lock.command-4LTGMJA3.js.map → lock.command-QQV2S6NY.js.map} +1 -1
- package/dist/plugin-lib.d.ts +2 -2
- package/dist/plugin-lib.js +2 -2
- package/dist/printenv.command-2BIP7FCF.js +15 -0
- package/dist/{printenv.command-EVYMVYEZ.js.map → printenv.command-2BIP7FCF.js.map} +1 -1
- package/dist/reveal.command-7LHNCYS4.js +15 -0
- package/dist/{reveal.command-6IH7XDVT.js.map → reveal.command-7LHNCYS4.js.map} +1 -1
- package/dist/run.command-TRSRYDOM.js +16 -0
- package/dist/{run.command-WW2YKPUP.js.map → run.command-TRSRYDOM.js.map} +1 -1
- package/dist/runtime/env.d.ts +1 -1
- package/dist/runtime/env.js +1 -1
- package/dist/runtime/init-edge.cjs +9 -1
- package/dist/runtime/init-server.cjs +9 -1
- package/dist/runtime/patch-console.js +2 -2
- package/dist/runtime/patch-response.js +2 -2
- package/dist/runtime/patch-server-response.js +2 -2
- package/dist/scan.command-NMBEPFUC.js +16 -0
- package/dist/{scan.command-6PSWFMI5.js.map → scan.command-NMBEPFUC.js.map} +1 -1
- package/dist/telemetry.command-SMIT5ZZB.js +13 -0
- package/dist/{telemetry.command-ZD6XCRBZ.js.map → telemetry.command-SMIT5ZZB.js.map} +1 -1
- package/dist/typegen.command-C5KWLYPL.js +14 -0
- package/dist/{typegen.command-IKXM7OSU.js.map → typegen.command-C5KWLYPL.js.map} +1 -1
- package/native-bins/darwin/VarlockEnclave.app/Contents/CodeResources +0 -0
- package/native-bins/darwin/VarlockEnclave.app/Contents/MacOS/varlock-local-encrypt +0 -0
- package/native-bins/linux-arm64/varlock-local-encrypt +0 -0
- package/native-bins/linux-x64/varlock-local-encrypt +0 -0
- package/native-bins/win32-x64/varlock-local-encrypt.exe +0 -0
- package/package.json +4 -3
- package/dist/audit.command-6TUJY57M.js +0 -16
- package/dist/chunk-26E4E2MY.js.map +0 -1
- package/dist/chunk-2PBFWISH.js.map +0 -1
- package/dist/chunk-45N5EFNL.js +0 -136
- package/dist/chunk-45N5EFNL.js.map +0 -1
- package/dist/chunk-4A54P4EM.js.map +0 -1
- package/dist/chunk-6CCHLM3U.js.map +0 -1
- package/dist/chunk-6CRDPEUT.js.map +0 -1
- package/dist/chunk-CWC3IAQM.js.map +0 -1
- package/dist/chunk-GURKQO4J.js.map +0 -1
- package/dist/chunk-MGWUDHT5.js.map +0 -1
- package/dist/config-item-7X6PUXJF.js +0 -7
- package/dist/encrypt.command-4E5SM5M6.js +0 -14
- package/dist/explain.command-7FRFYSJJ.js +0 -15
- package/dist/help.command-7E52XAOO.js +0 -5
- package/dist/init.command-EMPZK5D3.js +0 -14
- package/dist/install-plugin.command-SYQAPBII.js +0 -13
- package/dist/load.command-R7UTXX2X.js +0 -15
- package/dist/lock.command-4LTGMJA3.js +0 -7
- package/dist/printenv.command-EVYMVYEZ.js +0 -15
- package/dist/reveal.command-6IH7XDVT.js +0 -15
- package/dist/run.command-WW2YKPUP.js +0 -16
- package/dist/scan.command-6PSWFMI5.js +0 -16
- package/dist/telemetry.command-ZD6XCRBZ.js +0 -13
- package/dist/typegen.command-IKXM7OSU.js +0 -15
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
import { __name } from './chunk-6PEHRAEP.js';
|
|
2
2
|
|
|
3
|
-
// ../../node_modules/.bun/gunshi@0.
|
|
3
|
+
// ../../node_modules/.bun/gunshi@0.32.0/node_modules/gunshi/lib/core-D1daCTTE.js
|
|
4
|
+
var NOOP_EXTENSION = /* @__PURE__ */ __name(() => {
|
|
5
|
+
return /* @__PURE__ */ Object.create(null);
|
|
6
|
+
}, "NOOP_EXTENSION");
|
|
7
|
+
function plugin(options = {}) {
|
|
8
|
+
const { id, name, setup, onExtension, dependencies: dependencies2 } = options;
|
|
9
|
+
const extension2 = options.extension || NOOP_EXTENSION;
|
|
10
|
+
const pluginFn = /* @__PURE__ */ __name(async (ctx) => {
|
|
11
|
+
if (setup) await setup(ctx);
|
|
12
|
+
}, "pluginFn");
|
|
13
|
+
const props = {
|
|
14
|
+
writable: false,
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true
|
|
17
|
+
};
|
|
18
|
+
return Object.defineProperties(pluginFn, {
|
|
19
|
+
id: {
|
|
20
|
+
value: id,
|
|
21
|
+
...props
|
|
22
|
+
},
|
|
23
|
+
...name && { name: {
|
|
24
|
+
value: name,
|
|
25
|
+
...props
|
|
26
|
+
} },
|
|
27
|
+
...dependencies2 && { dependencies: {
|
|
28
|
+
value: dependencies2,
|
|
29
|
+
...props
|
|
30
|
+
} },
|
|
31
|
+
...extension2 && { extension: {
|
|
32
|
+
value: {
|
|
33
|
+
key: Symbol(id),
|
|
34
|
+
factory: extension2,
|
|
35
|
+
onFactory: onExtension
|
|
36
|
+
},
|
|
37
|
+
...props
|
|
38
|
+
} }
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
__name(plugin, "plugin");
|
|
42
|
+
|
|
43
|
+
// ../../node_modules/.bun/gunshi@0.32.0/node_modules/gunshi/lib/constants-D_ixLD32.js
|
|
44
|
+
var ANONYMOUS_COMMAND_NAME = "(anonymous)";
|
|
45
|
+
var NOOP = /* @__PURE__ */ __name(() => {
|
|
46
|
+
}, "NOOP");
|
|
47
|
+
var CLI_OPTIONS_DEFAULT = {
|
|
48
|
+
name: void 0,
|
|
49
|
+
description: void 0,
|
|
50
|
+
version: void 0,
|
|
51
|
+
cwd: void 0,
|
|
52
|
+
usageSilent: false,
|
|
53
|
+
subCommands: void 0,
|
|
54
|
+
leftMargin: 2,
|
|
55
|
+
middleMargin: 10,
|
|
56
|
+
usageOptionType: false,
|
|
57
|
+
usageOptionValue: true,
|
|
58
|
+
renderHeader: void 0,
|
|
59
|
+
renderUsage: void 0,
|
|
60
|
+
renderValidationErrors: void 0,
|
|
61
|
+
plugins: void 0,
|
|
62
|
+
fallbackToEntry: false
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// ../../node_modules/.bun/gunshi@0.32.0/node_modules/gunshi/lib/utils-jNy8sqR5.js
|
|
4
66
|
function kebabnize(str) {
|
|
5
67
|
return str.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? "-" : "") + match.toLowerCase());
|
|
6
68
|
}
|
|
@@ -76,1225 +138,1170 @@ function deepFreeze(obj, ignores = []) {
|
|
|
76
138
|
}
|
|
77
139
|
__name(deepFreeze, "deepFreeze");
|
|
78
140
|
|
|
79
|
-
// ../../node_modules/.bun/gunshi@0.
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
usageOptionType: false,
|
|
93
|
-
usageOptionValue: true,
|
|
94
|
-
renderHeader: void 0,
|
|
95
|
-
renderUsage: void 0,
|
|
96
|
-
renderValidationErrors: void 0,
|
|
97
|
-
plugins: void 0,
|
|
98
|
-
fallbackToEntry: false
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// ../../node_modules/.bun/gunshi@0.28.2/node_modules/gunshi/lib/context-CHDIbgwd.js
|
|
102
|
-
async function createCommandContext({ args = {}, explicit = {}, values = {}, positionals = [], rest = [], argv = [], tokens = [], command = {}, extensions = {}, cliOptions = {}, callMode = "entry", commandPath = [], omitted = false, validationError = void 0 }) {
|
|
103
|
-
const _args = Object.entries(args).reduce((acc, [key, value]) => {
|
|
104
|
-
acc[key] = Object.assign(create(), value);
|
|
105
|
-
return acc;
|
|
106
|
-
}, create());
|
|
107
|
-
const env = Object.assign(create(), CLI_OPTIONS_DEFAULT, cliOptions);
|
|
108
|
-
if (command.rendering) {
|
|
109
|
-
const { header, usage, validationErrors } = command.rendering;
|
|
110
|
-
if (header !== void 0) env.renderHeader = header;
|
|
111
|
-
if (usage !== void 0) env.renderUsage = usage;
|
|
112
|
-
if (validationErrors !== void 0) env.renderValidationErrors = validationErrors;
|
|
141
|
+
// ../../node_modules/.bun/gunshi@0.32.0/node_modules/gunshi/lib/src-dTYUlEw_.js
|
|
142
|
+
var BUILD_IN_PREFIX_AND_KEY_SEPARATOR = `_:`;
|
|
143
|
+
var ARG_PREFIX_AND_KEY_SEPARATOR = `arg:`;
|
|
144
|
+
var COMMON_ARGS = {
|
|
145
|
+
help: {
|
|
146
|
+
type: "boolean",
|
|
147
|
+
short: "h",
|
|
148
|
+
description: "Display this help message"
|
|
149
|
+
},
|
|
150
|
+
version: {
|
|
151
|
+
type: "boolean",
|
|
152
|
+
short: "v",
|
|
153
|
+
description: "Display this version"
|
|
113
154
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
155
|
+
};
|
|
156
|
+
var NEGATABLE = "Negatable of";
|
|
157
|
+
var en_US_default = {
|
|
158
|
+
COMMAND: "COMMAND",
|
|
159
|
+
COMMANDS: "COMMANDS",
|
|
160
|
+
SUBCOMMAND: "SUBCOMMAND",
|
|
161
|
+
USAGE: "USAGE",
|
|
162
|
+
ARGUMENTS: "ARGUMENTS",
|
|
163
|
+
OPTIONS: "OPTIONS",
|
|
164
|
+
EXAMPLES: "EXAMPLES",
|
|
165
|
+
FORMORE: "For more info, run any command with the `--help` flag",
|
|
166
|
+
NEGATABLE,
|
|
167
|
+
DEFAULT: "default",
|
|
168
|
+
CHOICES: "choices",
|
|
169
|
+
help: "Display this help message",
|
|
170
|
+
version: "Display this version"
|
|
171
|
+
};
|
|
172
|
+
function resolveBuiltInKey(key) {
|
|
173
|
+
return `_:${key}`;
|
|
174
|
+
}
|
|
175
|
+
__name(resolveBuiltInKey, "resolveBuiltInKey");
|
|
176
|
+
function resolveArgKey(key, name) {
|
|
177
|
+
return `${name ? `${name}:` : ""}arg:${key}`;
|
|
178
|
+
}
|
|
179
|
+
__name(resolveArgKey, "resolveArgKey");
|
|
180
|
+
function resolveKey(key, name) {
|
|
181
|
+
return `${name ? `${name}:` : ""}${key}`;
|
|
182
|
+
}
|
|
183
|
+
__name(resolveKey, "resolveKey");
|
|
184
|
+
async function resolveExamples$1(ctx, examples) {
|
|
185
|
+
return typeof examples === "string" ? examples : typeof examples === "function" ? await examples(ctx) : "";
|
|
186
|
+
}
|
|
187
|
+
__name(resolveExamples$1, "resolveExamples$1");
|
|
188
|
+
function namespacedId(id) {
|
|
189
|
+
return `g:${id}`;
|
|
190
|
+
}
|
|
191
|
+
__name(namespacedId, "namespacedId");
|
|
192
|
+
function makeShortLongOptionPair(schema, name, toKebab) {
|
|
193
|
+
let key = `--${toKebab || schema.toKebab ? kebabnize(name) : name}`;
|
|
194
|
+
if (schema.short) key = `-${schema.short}, ${key}`;
|
|
195
|
+
return key;
|
|
196
|
+
}
|
|
197
|
+
__name(makeShortLongOptionPair, "makeShortLongOptionPair");
|
|
198
|
+
function localizable(ctx, cmd, translate) {
|
|
199
|
+
async function localize(key, values) {
|
|
200
|
+
if (translate) return translate(key, values);
|
|
201
|
+
if (key.startsWith(BUILD_IN_PREFIX_AND_KEY_SEPARATOR)) return en_US_default[key.slice(BUILD_IN_PREFIX_AND_KEY_SEPARATOR.length)] || key;
|
|
202
|
+
const namaspacedArgKey = resolveKey(ARG_PREFIX_AND_KEY_SEPARATOR, ctx.name);
|
|
203
|
+
if (key.startsWith(namaspacedArgKey)) {
|
|
204
|
+
let argKey = key.slice(namaspacedArgKey.length);
|
|
205
|
+
let negatable = false;
|
|
206
|
+
if (argKey.startsWith("no-")) {
|
|
207
|
+
argKey = argKey.slice(3);
|
|
208
|
+
negatable = true;
|
|
209
|
+
}
|
|
210
|
+
const schema = ctx.args[argKey];
|
|
211
|
+
if (!schema) return argKey;
|
|
212
|
+
return negatable && schema.type === "boolean" && schema.negatable ? `${NEGATABLE} ${makeShortLongOptionPair(schema, argKey, ctx.toKebab)}` : schema.description || "";
|
|
143
213
|
}
|
|
214
|
+
if (key === resolveKey("description", ctx.name)) return "";
|
|
215
|
+
else if (key === resolveKey("examples", ctx.name)) return await resolveExamples$1(ctx, cmd.examples);
|
|
216
|
+
else return key;
|
|
144
217
|
}
|
|
145
|
-
|
|
218
|
+
__name(localize, "localize");
|
|
219
|
+
return localize;
|
|
146
220
|
}
|
|
147
|
-
__name(
|
|
148
|
-
function
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
else return ANONYMOUS_COMMAND_NAME;
|
|
221
|
+
__name(localizable, "localizable");
|
|
222
|
+
function renderHeader(ctx) {
|
|
223
|
+
const title = ctx.env.description || ctx.env.name || "";
|
|
224
|
+
return Promise.resolve(title ? `${title} (${ctx.env.name || ""}${ctx.env.version ? ` v${ctx.env.version}` : ""})` : title);
|
|
152
225
|
}
|
|
153
|
-
__name(
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
function
|
|
157
|
-
|
|
226
|
+
__name(renderHeader, "renderHeader");
|
|
227
|
+
var pluginId = namespacedId("renderer");
|
|
228
|
+
var COMMON_ARGS_KEYS = Object.keys(COMMON_ARGS);
|
|
229
|
+
async function renderUsage(ctx) {
|
|
230
|
+
const messages = [];
|
|
231
|
+
if (ctx.callMode === "subCommand") {
|
|
232
|
+
const description = await resolveDescription(ctx);
|
|
233
|
+
if (description) messages.push(description, "");
|
|
234
|
+
}
|
|
235
|
+
messages.push(...await renderUsageSection(ctx), "");
|
|
236
|
+
if (ctx.omitted && await hasCommands(ctx)) messages.push(...await renderCommandsSection(ctx), "");
|
|
237
|
+
if (hasPositionalArgs(ctx.args)) messages.push(...await renderPositionalArgsSection(ctx), "");
|
|
238
|
+
if (hasOptionalArgs(ctx.args)) messages.push(...await renderOptionalArgsSection(ctx), "");
|
|
239
|
+
const examples = await renderExamplesSection(ctx);
|
|
240
|
+
if (examples.length > 0) messages.push(...examples, "");
|
|
241
|
+
return messages.join("\n");
|
|
158
242
|
}
|
|
159
|
-
__name(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (groupCount > 0) groupCount--;
|
|
181
|
-
else index++;
|
|
182
|
-
if (arg === TERMINATOR) {
|
|
183
|
-
tokens.push({
|
|
184
|
-
kind: "option-terminator",
|
|
185
|
-
index
|
|
186
|
-
});
|
|
187
|
-
const mapped = remainings.map((arg2) => {
|
|
188
|
-
return {
|
|
189
|
-
kind: "positional",
|
|
190
|
-
index: ++index,
|
|
191
|
-
value: arg2
|
|
192
|
-
};
|
|
193
|
-
});
|
|
194
|
-
tokens.push(...mapped);
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
if (isShortOption(arg)) {
|
|
198
|
-
const shortOption = arg.charAt(1);
|
|
199
|
-
let value;
|
|
200
|
-
let inlineValue;
|
|
201
|
-
if (groupCount) {
|
|
202
|
-
tokens.push({
|
|
203
|
-
kind: "option",
|
|
204
|
-
name: shortOption,
|
|
205
|
-
rawName: arg,
|
|
206
|
-
index,
|
|
207
|
-
value,
|
|
208
|
-
inlineValue
|
|
209
|
-
});
|
|
210
|
-
if (groupCount === 1 && hasOptionValue(nextArg)) {
|
|
211
|
-
value = remainings.shift();
|
|
212
|
-
if (hasShortValueSeparator) {
|
|
213
|
-
inlineValue = true;
|
|
214
|
-
hasShortValueSeparator = false;
|
|
215
|
-
}
|
|
216
|
-
tokens.push({
|
|
217
|
-
kind: "option",
|
|
218
|
-
index,
|
|
219
|
-
value,
|
|
220
|
-
inlineValue
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
} else tokens.push({
|
|
224
|
-
kind: "option",
|
|
225
|
-
name: shortOption,
|
|
226
|
-
rawName: arg,
|
|
227
|
-
index,
|
|
228
|
-
value,
|
|
229
|
-
inlineValue
|
|
230
|
-
});
|
|
231
|
-
if (value != null) ++index;
|
|
232
|
-
continue;
|
|
233
|
-
}
|
|
234
|
-
if (isShortOptionGroup(arg)) {
|
|
235
|
-
const expanded = [];
|
|
236
|
-
let shortValue = "";
|
|
237
|
-
for (let i = 1; i < arg.length; i++) {
|
|
238
|
-
const shortableOption = arg.charAt(i);
|
|
239
|
-
if (hasShortValueSeparator) shortValue += shortableOption;
|
|
240
|
-
else if (!allowCompatible && shortableOption.codePointAt(0) === EQUAL_CODE) hasShortValueSeparator = true;
|
|
241
|
-
else expanded.push(`${SHORT_OPTION_PREFIX}${shortableOption}`);
|
|
242
|
-
}
|
|
243
|
-
if (shortValue) expanded.push(shortValue);
|
|
244
|
-
remainings.unshift(...expanded);
|
|
245
|
-
groupCount = expanded.length;
|
|
246
|
-
continue;
|
|
247
|
-
}
|
|
248
|
-
if (isLongOption(arg)) {
|
|
249
|
-
const longOption = arg.slice(2);
|
|
250
|
-
tokens.push({
|
|
251
|
-
kind: "option",
|
|
252
|
-
name: longOption,
|
|
253
|
-
rawName: arg,
|
|
254
|
-
index,
|
|
255
|
-
value: void 0,
|
|
256
|
-
inlineValue: void 0
|
|
257
|
-
});
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
if (isLongOptionAndValue(arg)) {
|
|
261
|
-
const equalIndex = arg.indexOf(EQUAL_CHAR);
|
|
262
|
-
const longOption = arg.slice(2, equalIndex);
|
|
263
|
-
const value = arg.slice(equalIndex + 1);
|
|
264
|
-
tokens.push({
|
|
265
|
-
kind: "option",
|
|
266
|
-
name: longOption,
|
|
267
|
-
rawName: `${LONG_OPTION_PREFIX}${longOption}`,
|
|
268
|
-
index,
|
|
269
|
-
value,
|
|
270
|
-
inlineValue: true
|
|
271
|
-
});
|
|
272
|
-
continue;
|
|
273
|
-
}
|
|
274
|
-
tokens.push({
|
|
275
|
-
kind: "positional",
|
|
276
|
-
index,
|
|
277
|
-
value: arg
|
|
278
|
-
});
|
|
243
|
+
__name(renderUsage, "renderUsage");
|
|
244
|
+
async function renderPositionalArgsSection(ctx) {
|
|
245
|
+
const messages = [];
|
|
246
|
+
messages.push(`${await ctx.extensions[pluginId].text(resolveBuiltInKey("ARGUMENTS"))}:`);
|
|
247
|
+
messages.push(await generatePositionalArgsUsage(ctx));
|
|
248
|
+
return messages;
|
|
249
|
+
}
|
|
250
|
+
__name(renderPositionalArgsSection, "renderPositionalArgsSection");
|
|
251
|
+
async function renderOptionalArgsSection(ctx) {
|
|
252
|
+
const messages = [];
|
|
253
|
+
messages.push(`${await ctx.extensions[pluginId].text(resolveBuiltInKey("OPTIONS"))}:`);
|
|
254
|
+
messages.push(await generateOptionalArgsUsage(ctx, getOptionalArgsPairs(ctx)));
|
|
255
|
+
return messages;
|
|
256
|
+
}
|
|
257
|
+
__name(renderOptionalArgsSection, "renderOptionalArgsSection");
|
|
258
|
+
async function renderExamplesSection(ctx) {
|
|
259
|
+
const messages = [];
|
|
260
|
+
const resolvedExamples = await resolveExamples(ctx);
|
|
261
|
+
if (resolvedExamples) {
|
|
262
|
+
const examples = resolvedExamples.split("\n").map((example) => example.padStart(ctx.env.leftMargin + example.length));
|
|
263
|
+
messages.push(`${await ctx.extensions[pluginId].text(resolveBuiltInKey("EXAMPLES"))}:`, ...examples);
|
|
279
264
|
}
|
|
280
|
-
return
|
|
265
|
+
return messages;
|
|
281
266
|
}
|
|
282
|
-
__name(
|
|
283
|
-
function
|
|
284
|
-
|
|
267
|
+
__name(renderExamplesSection, "renderExamplesSection");
|
|
268
|
+
async function renderUsageSection(ctx) {
|
|
269
|
+
const messages = [`${await ctx.extensions[pluginId].text(resolveBuiltInKey("USAGE"))}:`];
|
|
270
|
+
const usageStr = await makeUsageSymbols(ctx);
|
|
271
|
+
messages.push(usageStr.padStart(ctx.env.leftMargin + usageStr.length));
|
|
272
|
+
return messages;
|
|
285
273
|
}
|
|
286
|
-
__name(
|
|
287
|
-
function
|
|
288
|
-
|
|
289
|
-
if (
|
|
290
|
-
|
|
291
|
-
|
|
274
|
+
__name(renderUsageSection, "renderUsageSection");
|
|
275
|
+
async function makeUsageSymbols(ctx) {
|
|
276
|
+
const messages = [await resolveEntry(ctx)];
|
|
277
|
+
if (ctx.omitted) if (await hasCommands(ctx)) messages.push(` [${await ctx.extensions[pluginId].text(resolveBuiltInKey("COMMANDS"))}]`);
|
|
278
|
+
else messages.push(`${ctx.callMode === "subCommand" ? ` ${await resolveSubCommand(ctx)}` : ""}`);
|
|
279
|
+
else messages.push(`${ctx.callMode === "subCommand" ? ` ${await resolveSubCommand(ctx)}` : ""}`);
|
|
280
|
+
const optionsSymbols = await generateOptionsSymbols(ctx, ctx.args);
|
|
281
|
+
if (optionsSymbols) messages.push(" ", optionsSymbols);
|
|
282
|
+
const positionalSymbols = generatePositionalSymbols(ctx.args);
|
|
283
|
+
if (positionalSymbols) messages.push(" ", positionalSymbols);
|
|
284
|
+
return messages.join("");
|
|
292
285
|
}
|
|
293
|
-
__name(
|
|
294
|
-
function
|
|
295
|
-
|
|
286
|
+
__name(makeUsageSymbols, "makeUsageSymbols");
|
|
287
|
+
async function renderCommandsSection(ctx) {
|
|
288
|
+
const messages = [`${await ctx.extensions[pluginId].text(resolveBuiltInKey("COMMANDS"))}:`];
|
|
289
|
+
const loadedCommands = await ctx.extensions?.[pluginId].loadCommands() || [];
|
|
290
|
+
const commandMaxLength = Math.max(...loadedCommands.map((cmd) => (cmd.name || "").length));
|
|
291
|
+
const commandsStr = await Promise.all(loadedCommands.map(async (cmd) => {
|
|
292
|
+
const desc = cmd.description || "";
|
|
293
|
+
const optionSymbol = await generateOptionsSymbols(ctx, ctx.args);
|
|
294
|
+
const positionalSymbol = generatePositionalSymbols(ctx.args);
|
|
295
|
+
const commandStr = await makeCommandSymbol(ctx, cmd);
|
|
296
|
+
const symbolLength = desc.length > 0 ? commandMaxLength + optionSymbol.length + positionalSymbol.length : 0;
|
|
297
|
+
const command = `${commandStr.padEnd(symbolLength + ctx.env.middleMargin)}${desc}`;
|
|
298
|
+
return `${command.padStart(ctx.env.leftMargin + command.length)}`;
|
|
299
|
+
}));
|
|
300
|
+
messages.push(...commandsStr, "", `${await ctx.extensions[pluginId].text(resolveBuiltInKey("FORMORE"))}:`);
|
|
301
|
+
const basePath = ctx.commandPath && ctx.commandPath.length > 0 ? `${ctx.env.name} ${ctx.commandPath.join(" ")}` : ctx.env.name;
|
|
302
|
+
messages.push(...loadedCommands.map((cmd) => {
|
|
303
|
+
let commandStr = cmd.entry ? "" : cmd.name || "";
|
|
304
|
+
if (commandStr) commandStr += " ";
|
|
305
|
+
const commandHelp = `${basePath} ${commandStr}--help`;
|
|
306
|
+
return `${commandHelp.padStart(ctx.env.leftMargin + commandHelp.length)}`;
|
|
307
|
+
}));
|
|
308
|
+
return messages;
|
|
296
309
|
}
|
|
297
|
-
__name(
|
|
298
|
-
function
|
|
299
|
-
|
|
310
|
+
__name(renderCommandsSection, "renderCommandsSection");
|
|
311
|
+
async function makeCommandSymbol(ctx, cmd) {
|
|
312
|
+
const optionSymbol = await generateOptionsSymbols(ctx, ctx.args);
|
|
313
|
+
const positionalSymbol = generatePositionalSymbols(ctx.args);
|
|
314
|
+
let commandStr = cmd.entry ? cmd.name === void 0 || cmd.name === "(anonymous)" ? "" : `[${cmd.name}]` : cmd.name || "";
|
|
315
|
+
if (optionSymbol) {
|
|
316
|
+
if (commandStr) commandStr += " ";
|
|
317
|
+
commandStr += `${optionSymbol}`;
|
|
318
|
+
}
|
|
319
|
+
if (positionalSymbol) {
|
|
320
|
+
if (commandStr) commandStr += " ";
|
|
321
|
+
commandStr += `${positionalSymbol}`;
|
|
322
|
+
}
|
|
323
|
+
return commandStr;
|
|
300
324
|
}
|
|
301
|
-
__name(
|
|
302
|
-
function
|
|
303
|
-
return
|
|
325
|
+
__name(makeCommandSymbol, "makeCommandSymbol");
|
|
326
|
+
async function resolveEntry(ctx) {
|
|
327
|
+
return ctx.env.name || await ctx.extensions[pluginId].text(resolveBuiltInKey("COMMAND"));
|
|
304
328
|
}
|
|
305
|
-
__name(
|
|
306
|
-
function
|
|
307
|
-
|
|
329
|
+
__name(resolveEntry, "resolveEntry");
|
|
330
|
+
async function resolveSubCommand(ctx) {
|
|
331
|
+
if (ctx.commandPath && ctx.commandPath.length > 0) return ctx.commandPath.join(" ");
|
|
332
|
+
return ctx.name || await ctx.extensions[pluginId].text(resolveBuiltInKey("SUBCOMMAND"));
|
|
308
333
|
}
|
|
309
|
-
__name(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
334
|
+
__name(resolveSubCommand, "resolveSubCommand");
|
|
335
|
+
async function resolveDescription(ctx) {
|
|
336
|
+
return await ctx.extensions[pluginId].text(resolveKey("description", ctx.name)) || ctx.description || "";
|
|
337
|
+
}
|
|
338
|
+
__name(resolveDescription, "resolveDescription");
|
|
339
|
+
async function resolveExamples(ctx) {
|
|
340
|
+
const ret = await ctx.extensions[pluginId].text(resolveKey("examples", ctx.name));
|
|
341
|
+
if (ret) return ret;
|
|
342
|
+
const command = ctx.env.subCommands?.get(ctx.name || "");
|
|
343
|
+
return await resolveExamples$1(ctx, command?.examples);
|
|
344
|
+
}
|
|
345
|
+
__name(resolveExamples, "resolveExamples");
|
|
346
|
+
async function hasCommands(ctx) {
|
|
347
|
+
return (await ctx.extensions?.[pluginId].loadCommands() || []).length > 1;
|
|
348
|
+
}
|
|
349
|
+
__name(hasCommands, "hasCommands");
|
|
350
|
+
function hasOptionalArgs(args) {
|
|
351
|
+
return Object.values(args).some((arg) => arg.type !== "positional");
|
|
352
|
+
}
|
|
353
|
+
__name(hasOptionalArgs, "hasOptionalArgs");
|
|
354
|
+
function hasPositionalArgs(args) {
|
|
355
|
+
return Object.values(args).some((arg) => arg.type === "positional");
|
|
356
|
+
}
|
|
357
|
+
__name(hasPositionalArgs, "hasPositionalArgs");
|
|
358
|
+
function hasAllDefaultOptions(args) {
|
|
359
|
+
return !!(args && Object.values(args).every((arg) => arg.default));
|
|
360
|
+
}
|
|
361
|
+
__name(hasAllDefaultOptions, "hasAllDefaultOptions");
|
|
362
|
+
async function generateOptionsSymbols(ctx, args) {
|
|
363
|
+
return hasOptionalArgs(args) ? hasAllDefaultOptions(args) ? `[${await ctx.extensions[pluginId].text(resolveBuiltInKey("OPTIONS"))}]` : `<${await ctx.extensions[pluginId].text(resolveBuiltInKey("OPTIONS"))}>` : "";
|
|
364
|
+
}
|
|
365
|
+
__name(generateOptionsSymbols, "generateOptionsSymbols");
|
|
366
|
+
function getOptionalArgsPairs(ctx) {
|
|
367
|
+
return Object.entries(ctx.args).reduce((acc, [name, schema]) => {
|
|
368
|
+
if (schema.type === "positional") return acc;
|
|
369
|
+
let key = makeShortLongOptionPair(schema, name, ctx.toKebab);
|
|
370
|
+
if (schema.type !== "boolean") {
|
|
371
|
+
const displayName = ctx.toKebab || schema.toKebab ? kebabnize(name) : name;
|
|
372
|
+
key = schema.default ? `${key} [${displayName}]` : `${key} <${displayName}>`;
|
|
333
373
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
currentShortOption.value = value || toShortValue();
|
|
339
|
-
optionTokens.push({ ...currentShortOption });
|
|
340
|
-
currentShortOption = void 0;
|
|
374
|
+
acc[name] = key;
|
|
375
|
+
if (schema.type === "boolean" && schema.negatable && !COMMON_ARGS_KEYS.includes(name)) {
|
|
376
|
+
const displayName = ctx.toKebab || schema.toKebab ? kebabnize(name) : name;
|
|
377
|
+
acc[`no-${name}`] = `--no-${displayName}`;
|
|
341
378
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
const schemas = Object.values(args);
|
|
345
|
-
let terminated = false;
|
|
346
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
347
|
-
const token = tokens[i];
|
|
348
|
-
if (token.kind === "positional") {
|
|
349
|
-
if (terminated && token.value) {
|
|
350
|
-
rest.push(token.value);
|
|
351
|
-
continue;
|
|
352
|
-
}
|
|
353
|
-
if (currentShortOption) {
|
|
354
|
-
if (schemas.find((schema) => schema.short === currentShortOption.name && schema.type === "boolean")) positionalTokens.push({ ...token });
|
|
355
|
-
} else if (currentLongOption) {
|
|
356
|
-
if (args[currentLongOption.name]?.type === "boolean") positionalTokens.push({ ...token });
|
|
357
|
-
} else positionalTokens.push({ ...token });
|
|
358
|
-
applyLongOptionValue(token.value);
|
|
359
|
-
applyShortOptionValue(token.value);
|
|
360
|
-
} else if (token.kind === "option") if (token.rawName) {
|
|
361
|
-
if (hasLongOptionPrefix(token.rawName)) {
|
|
362
|
-
applyLongOptionValue();
|
|
363
|
-
if (token.inlineValue) optionTokens.push({ ...token });
|
|
364
|
-
else currentLongOption = { ...token };
|
|
365
|
-
applyShortOptionValue();
|
|
366
|
-
} else if (isShortOption(token.rawName)) if (currentShortOption) {
|
|
367
|
-
if (currentShortOption.index === token.index) if (shortGrouping) {
|
|
368
|
-
currentShortOption.value = token.value;
|
|
369
|
-
optionTokens.push({ ...currentShortOption });
|
|
370
|
-
currentShortOption = { ...token };
|
|
371
|
-
} else expandableShortOptions.push({ ...token });
|
|
372
|
-
else {
|
|
373
|
-
currentShortOption.value = toShortValue();
|
|
374
|
-
optionTokens.push({ ...currentShortOption });
|
|
375
|
-
currentShortOption = { ...token };
|
|
376
|
-
}
|
|
377
|
-
applyLongOptionValue();
|
|
378
|
-
} else {
|
|
379
|
-
currentShortOption = { ...token };
|
|
380
|
-
applyLongOptionValue();
|
|
381
|
-
}
|
|
382
|
-
} else {
|
|
383
|
-
if (currentShortOption && currentShortOption.index == token.index && token.inlineValue) {
|
|
384
|
-
currentShortOption.value = token.value;
|
|
385
|
-
optionTokens.push({ ...currentShortOption });
|
|
386
|
-
currentShortOption = void 0;
|
|
387
|
-
}
|
|
388
|
-
applyLongOptionValue();
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
if (token.kind === "option-terminator") terminated = true;
|
|
392
|
-
applyLongOptionValue();
|
|
393
|
-
applyShortOptionValue();
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
applyLongOptionValue();
|
|
397
|
-
applyShortOptionValue();
|
|
398
|
-
const values = /* @__PURE__ */ Object.create(null);
|
|
399
|
-
const errors = [];
|
|
400
|
-
const explicit = /* @__PURE__ */ Object.create(null);
|
|
401
|
-
const actualInputNames = /* @__PURE__ */ new Map();
|
|
402
|
-
function checkTokenName(option, schema, token) {
|
|
403
|
-
return token.name === (schema.type === "boolean" ? schema.negatable && token.name?.startsWith("no-") ? `no-${option}` : option : option);
|
|
404
|
-
}
|
|
405
|
-
__name(checkTokenName, "checkTokenName");
|
|
406
|
-
const positionalItemCount = tokens.filter((token) => token.kind === "positional").length;
|
|
407
|
-
function getPositionalSkipIndex() {
|
|
408
|
-
return Math.min(skipPositionalIndex, positionalItemCount);
|
|
409
|
-
}
|
|
410
|
-
__name(getPositionalSkipIndex, "getPositionalSkipIndex");
|
|
411
|
-
let positionalsCount = 0;
|
|
412
|
-
for (const [rawArg, schema] of Object.entries(args)) {
|
|
413
|
-
const arg = toKebab || schema.toKebab ? kebabnize(rawArg) : rawArg;
|
|
414
|
-
explicit[rawArg] = false;
|
|
415
|
-
if (schema.type === "positional") {
|
|
416
|
-
if (skipPositionalIndex > SKIP_POSITIONAL_DEFAULT) while (positionalsCount <= getPositionalSkipIndex()) positionalsCount++;
|
|
417
|
-
if (schema.multiple) {
|
|
418
|
-
const remainingPositionals = positionalTokens.slice(positionalsCount);
|
|
419
|
-
if (remainingPositionals.length > 0) {
|
|
420
|
-
values[rawArg] = remainingPositionals.map((p) => p.value);
|
|
421
|
-
positionalsCount += remainingPositionals.length;
|
|
422
|
-
explicit[rawArg] = true;
|
|
423
|
-
} else if (schema.required) errors.push(createRequireError(arg, schema));
|
|
424
|
-
} else {
|
|
425
|
-
const positional = positionalTokens[positionalsCount];
|
|
426
|
-
if (positional != null) {
|
|
427
|
-
values[rawArg] = positional.value;
|
|
428
|
-
explicit[rawArg] = true;
|
|
429
|
-
} else errors.push(createRequireError(arg, schema));
|
|
430
|
-
positionalsCount++;
|
|
431
|
-
}
|
|
432
|
-
continue;
|
|
433
|
-
}
|
|
434
|
-
if (schema.required) {
|
|
435
|
-
if (!optionTokens.find((token) => {
|
|
436
|
-
return schema.short && token.name === schema.short || token.rawName && hasLongOptionPrefix(token.rawName) && token.name === arg;
|
|
437
|
-
})) {
|
|
438
|
-
errors.push(createRequireError(arg, schema));
|
|
439
|
-
continue;
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
for (let i = 0; i < optionTokens.length; i++) {
|
|
443
|
-
const token = optionTokens[i];
|
|
444
|
-
if (checkTokenName(arg, schema, token) && token.rawName != void 0 && hasLongOptionPrefix(token.rawName) || schema.short === token.name && token.rawName != void 0 && isShortOption(token.rawName)) {
|
|
445
|
-
const invalid = validateRequire(token, arg, schema);
|
|
446
|
-
if (invalid) {
|
|
447
|
-
errors.push(invalid);
|
|
448
|
-
continue;
|
|
449
|
-
}
|
|
450
|
-
explicit[rawArg] = true;
|
|
451
|
-
const actualInputName = isShortOption(token.rawName) ? `-${token.name}` : `--${arg}`;
|
|
452
|
-
actualInputNames.set(rawArg, actualInputName);
|
|
453
|
-
if (schema.type === "boolean") token.value = void 0;
|
|
454
|
-
const [parsedValue, error] = parse(token, arg, schema);
|
|
455
|
-
if (error) errors.push(error);
|
|
456
|
-
else if (schema.multiple) {
|
|
457
|
-
values[rawArg] ||= [];
|
|
458
|
-
values[rawArg].push(parsedValue);
|
|
459
|
-
} else values[rawArg] = parsedValue;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
if (values[rawArg] == null && schema.default != null) values[rawArg] = schema.default;
|
|
463
|
-
}
|
|
464
|
-
const conflictErrors = checkConflicts(args, explicit, toKebab, actualInputNames);
|
|
465
|
-
errors.push(...conflictErrors);
|
|
466
|
-
return {
|
|
467
|
-
values,
|
|
468
|
-
positionals: positionalTokens.map((token) => token.value),
|
|
469
|
-
rest,
|
|
470
|
-
error: errors.length > 0 ? new AggregateError(errors) : void 0,
|
|
471
|
-
explicit
|
|
472
|
-
};
|
|
379
|
+
return acc;
|
|
380
|
+
}, /* @__PURE__ */ Object.create(null));
|
|
473
381
|
}
|
|
474
|
-
__name(
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
return typeof token.value === "string" ? [token.value || schema.default, void 0] : [void 0, createTypeError(option, schema)];
|
|
479
|
-
case "boolean":
|
|
480
|
-
return token.value ? [token.value || schema.default, void 0] : [!(schema.negatable && token.name.startsWith("no-")), void 0];
|
|
481
|
-
case "number":
|
|
482
|
-
if (!isNumeric(token.value)) return [void 0, createTypeError(option, schema)];
|
|
483
|
-
return token.value ? [+token.value, void 0] : [+(schema.default || ""), void 0];
|
|
484
|
-
case "enum":
|
|
485
|
-
if (schema.choices && !schema.choices.includes(token.value)) return [void 0, new ArgResolveError(`Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}should be chosen from '${schema.type}' [${schema.choices.map((c) => JSON.stringify(c)).join(", ")}] values`, option, "type", schema)];
|
|
486
|
-
return [token.value || schema.default, void 0];
|
|
487
|
-
case "custom":
|
|
488
|
-
if (typeof schema.parse !== "function") throw new TypeError(`argument '${option}' should have a 'parse' function`);
|
|
489
|
-
try {
|
|
490
|
-
return [schema.parse(token.value || String(schema.default || "")), void 0];
|
|
491
|
-
} catch (error) {
|
|
492
|
-
return [void 0, error];
|
|
493
|
-
}
|
|
494
|
-
default:
|
|
495
|
-
throw new Error(`Unsupported argument type '${schema.type}' for option '${option}'`);
|
|
496
|
-
}
|
|
382
|
+
__name(getOptionalArgsPairs, "getOptionalArgsPairs");
|
|
383
|
+
var resolveNegatableKey = /* @__PURE__ */ __name((key) => key.split("no-")[1], "resolveNegatableKey");
|
|
384
|
+
function resolveNegatableType(key, ctx) {
|
|
385
|
+
return ctx.args[key.startsWith("no-") ? resolveNegatableKey(key) : key].type;
|
|
497
386
|
}
|
|
498
|
-
__name(
|
|
499
|
-
function
|
|
500
|
-
return
|
|
387
|
+
__name(resolveNegatableType, "resolveNegatableType");
|
|
388
|
+
async function generateDefaultDisplayValue(ctx, schema) {
|
|
389
|
+
return `${await ctx.extensions[pluginId].text(resolveBuiltInKey("DEFAULT"))}: ${schema.default}`;
|
|
501
390
|
}
|
|
502
|
-
__name(
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
* Create an `ArgResolveError` instance.
|
|
512
|
-
*
|
|
513
|
-
* @param message - the error message
|
|
514
|
-
* @param name - the name of the argument
|
|
515
|
-
* @param type - the type of the error, either 'type' or 'required'
|
|
516
|
-
* @param schema - the argument schema that caused the error
|
|
517
|
-
*/
|
|
518
|
-
constructor(message, name, type, schema) {
|
|
519
|
-
super(message);
|
|
520
|
-
this.name = name;
|
|
521
|
-
this.type = type;
|
|
522
|
-
this.schema = schema;
|
|
391
|
+
__name(generateDefaultDisplayValue, "generateDefaultDisplayValue");
|
|
392
|
+
async function resolveDisplayValue(ctx, key) {
|
|
393
|
+
if (COMMON_ARGS_KEYS.includes(key)) return "";
|
|
394
|
+
const schema = ctx.args[key];
|
|
395
|
+
if ((schema.type === "boolean" || schema.type === "number" || schema.type === "string" || schema.type === "custom") && schema.default !== void 0) return `(${await generateDefaultDisplayValue(ctx, schema)})`;
|
|
396
|
+
if (schema.type === "enum") {
|
|
397
|
+
const _default = schema.default === void 0 ? "" : await generateDefaultDisplayValue(ctx, schema);
|
|
398
|
+
const choices = `${await ctx.extensions[pluginId].text(resolveBuiltInKey("CHOICES"))}: ${schema.choices.join(" | ")}`;
|
|
399
|
+
return `(${_default ? `${_default}, ${choices}` : choices})`;
|
|
523
400
|
}
|
|
524
|
-
|
|
525
|
-
function validateRequire(token, option, schema) {
|
|
526
|
-
if (schema.required && schema.type !== "boolean" && !token.value) return createRequireError(option, schema);
|
|
527
|
-
}
|
|
528
|
-
__name(validateRequire, "validateRequire");
|
|
529
|
-
function isNumeric(str) {
|
|
530
|
-
return str.trim() !== "" && !isNaN(str);
|
|
531
|
-
}
|
|
532
|
-
__name(isNumeric, "isNumeric");
|
|
533
|
-
function createTypeError(option, schema) {
|
|
534
|
-
return new ArgResolveError(`Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}should be '${schema.type}'`, option, "type", schema);
|
|
401
|
+
return "";
|
|
535
402
|
}
|
|
536
|
-
__name(
|
|
537
|
-
function
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
const conflictingArgKebab = toKebab || args[conflictingArg]?.toKebab ? kebabnize(conflictingArg) : conflictingArg;
|
|
548
|
-
return [new ArgResolveError(`Optional argument '${actualInputNames.get(rawArg) || `--${arg}`}' conflicts with '${actualInputNames.get(conflictingArg) || `--${conflictingArgKebab}`}'`, rawArg, "conflict", schema)];
|
|
403
|
+
__name(resolveDisplayValue, "resolveDisplayValue");
|
|
404
|
+
async function generateOptionalArgsUsage(ctx, optionsPairs) {
|
|
405
|
+
const optionsMaxLength = Math.max(...Object.entries(optionsPairs).map(([_, value]) => value.length));
|
|
406
|
+
const optionSchemaMaxLength = ctx.env.usageOptionType ? Math.max(...Object.entries(optionsPairs).map(([key]) => resolveNegatableType(key, ctx).length)) : 0;
|
|
407
|
+
return (await Promise.all(Object.entries(optionsPairs).map(async ([key, value]) => {
|
|
408
|
+
let rawDesc = await ctx.extensions[pluginId].text(resolveArgKey(key, ctx.name));
|
|
409
|
+
if (!rawDesc && key.startsWith("no-")) {
|
|
410
|
+
const name = resolveNegatableKey(key);
|
|
411
|
+
const schema = ctx.args[name];
|
|
412
|
+
const optionKey = makeShortLongOptionPair(schema, name, ctx.toKebab);
|
|
413
|
+
rawDesc = `${await ctx.extensions[pluginId].text(resolveBuiltInKey("NEGATABLE"))} ${optionKey}`;
|
|
549
414
|
}
|
|
550
|
-
|
|
551
|
-
|
|
415
|
+
const optionsSchema = ctx.env.usageOptionType ? `[${resolveNegatableType(key, ctx)}] ` : "";
|
|
416
|
+
const valueDesc = key.startsWith("no-") ? "" : await resolveDisplayValue(ctx, key);
|
|
417
|
+
const desc = `${optionsSchema ? optionsSchema.padEnd(optionSchemaMaxLength + 3) : ""}${rawDesc}`;
|
|
418
|
+
const descLength = desc.length + valueDesc.length;
|
|
419
|
+
const option = `${value.padEnd((descLength > 0 ? optionsMaxLength : 0) + ctx.env.middleMargin)}${desc}${valueDesc ? ` ${valueDesc}` : ""}`;
|
|
420
|
+
return `${option.padStart(ctx.env.leftMargin + option.length)}`;
|
|
421
|
+
}))).join("\n");
|
|
552
422
|
}
|
|
553
|
-
__name(
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
const headerDecorators = [];
|
|
557
|
-
const usageDecorators = [];
|
|
558
|
-
const validationDecorators = [];
|
|
559
|
-
const commandDecorators = [];
|
|
560
|
-
function buildRenderer(decorators, defaultRenderer) {
|
|
561
|
-
if (decorators.length === 0) return defaultRenderer;
|
|
562
|
-
let renderer2 = defaultRenderer;
|
|
563
|
-
for (const decorator2 of decorators) {
|
|
564
|
-
const previousRenderer = renderer2;
|
|
565
|
-
renderer2 = /* @__PURE__ */ __name((ctx) => decorator2(previousRenderer, ctx), "renderer");
|
|
566
|
-
}
|
|
567
|
-
return renderer2;
|
|
568
|
-
}
|
|
569
|
-
__name(buildRenderer, "buildRenderer");
|
|
570
|
-
return Object.freeze({
|
|
571
|
-
addHeaderDecorator(decorator2) {
|
|
572
|
-
headerDecorators.push(decorator2);
|
|
573
|
-
},
|
|
574
|
-
addUsageDecorator(decorator2) {
|
|
575
|
-
usageDecorators.push(decorator2);
|
|
576
|
-
},
|
|
577
|
-
addValidationErrorsDecorator(decorator2) {
|
|
578
|
-
validationDecorators.push(decorator2);
|
|
579
|
-
},
|
|
580
|
-
addCommandDecorator(decorator2) {
|
|
581
|
-
commandDecorators.push(decorator2);
|
|
582
|
-
},
|
|
583
|
-
get commandDecorators() {
|
|
584
|
-
return [...commandDecorators];
|
|
585
|
-
},
|
|
586
|
-
getHeaderRenderer() {
|
|
587
|
-
return buildRenderer(headerDecorators, EMPTY_RENDERER);
|
|
588
|
-
},
|
|
589
|
-
getUsageRenderer() {
|
|
590
|
-
return buildRenderer(usageDecorators, EMPTY_RENDERER);
|
|
591
|
-
},
|
|
592
|
-
getValidationErrorsRenderer() {
|
|
593
|
-
if (validationDecorators.length === 0) return EMPTY_RENDERER;
|
|
594
|
-
let renderer2 = EMPTY_RENDERER;
|
|
595
|
-
for (const decorator2 of validationDecorators) {
|
|
596
|
-
const previousRenderer = renderer2;
|
|
597
|
-
renderer2 = /* @__PURE__ */ __name((ctx, error) => decorator2(previousRenderer, ctx, error), "renderer");
|
|
598
|
-
}
|
|
599
|
-
return renderer2;
|
|
600
|
-
}
|
|
601
|
-
});
|
|
423
|
+
__name(generateOptionalArgsUsage, "generateOptionalArgsUsage");
|
|
424
|
+
function getPositionalArgs(args) {
|
|
425
|
+
return Object.entries(args).filter(([_, schema]) => schema.type === "positional");
|
|
602
426
|
}
|
|
603
|
-
__name(
|
|
604
|
-
function
|
|
605
|
-
const
|
|
606
|
-
const
|
|
607
|
-
return
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
if (!name) throw new Error("Option name must be a non-empty string");
|
|
613
|
-
if (globalOptions.has(name)) throw new Error(`Global option '${name}' is already registered`);
|
|
614
|
-
globalOptions.set(name, schema);
|
|
615
|
-
},
|
|
616
|
-
get subCommands() {
|
|
617
|
-
return new Map(subCommands);
|
|
618
|
-
},
|
|
619
|
-
addCommand(name, command) {
|
|
620
|
-
if (!name) throw new Error("Command name must be a non-empty string");
|
|
621
|
-
if (subCommands.has(name)) throw new Error(`Command '${name}' is already registered`);
|
|
622
|
-
subCommands.set(name, command);
|
|
623
|
-
},
|
|
624
|
-
hasCommand(name) {
|
|
625
|
-
return subCommands.has(name);
|
|
626
|
-
},
|
|
627
|
-
decorateHeaderRenderer(decorator2) {
|
|
628
|
-
decorators.addHeaderDecorator(decorator2);
|
|
629
|
-
},
|
|
630
|
-
decorateUsageRenderer(decorator2) {
|
|
631
|
-
decorators.addUsageDecorator(decorator2);
|
|
632
|
-
},
|
|
633
|
-
decorateValidationErrorsRenderer(decorator2) {
|
|
634
|
-
decorators.addValidationErrorsDecorator(decorator2);
|
|
635
|
-
},
|
|
636
|
-
decorateCommand(decorator2) {
|
|
637
|
-
decorators.addCommandDecorator(decorator2);
|
|
638
|
-
}
|
|
639
|
-
});
|
|
427
|
+
__name(getPositionalArgs, "getPositionalArgs");
|
|
428
|
+
async function generatePositionalArgsUsage(ctx) {
|
|
429
|
+
const positionals = getPositionalArgs(ctx.args);
|
|
430
|
+
const argsMaxLength = Math.max(...positionals.map(([name]) => name.length));
|
|
431
|
+
return (await Promise.all(positionals.map(async ([name]) => {
|
|
432
|
+
const desc = await ctx.extensions[pluginId].text(resolveArgKey(name, ctx.name)) || ctx.args[name].description || "";
|
|
433
|
+
const arg = `${name.padEnd(argsMaxLength + ctx.env.middleMargin)} ${desc}`;
|
|
434
|
+
return `${arg.padStart(ctx.env.leftMargin + arg.length)}`;
|
|
435
|
+
}))).join("\n");
|
|
640
436
|
}
|
|
641
|
-
__name(
|
|
642
|
-
function
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
pluginMap.set(plugin2.id, plugin2);
|
|
650
|
-
}
|
|
651
|
-
function visit(plugin2) {
|
|
652
|
-
if (!plugin2.id) return;
|
|
653
|
-
if (visited.has(plugin2.id)) return;
|
|
654
|
-
if (visiting.has(plugin2.id)) throw new Error(`Circular dependency detected: \`${[...visiting].join(` -> `) + " -> " + plugin2.id}\``);
|
|
655
|
-
visiting.add(plugin2.id);
|
|
656
|
-
const deps = plugin2.dependencies || [];
|
|
657
|
-
for (const dep of deps) {
|
|
658
|
-
const depId = typeof dep === "string" ? dep : dep.id;
|
|
659
|
-
const isOptional = typeof dep === "string" ? false : dep.optional || false;
|
|
660
|
-
const depPlugin = pluginMap.get(depId);
|
|
661
|
-
if (!depPlugin && !isOptional) throw new Error(`Missing required dependency: \`${depId}\` on \`${plugin2.id}\``);
|
|
662
|
-
if (depPlugin) visit(depPlugin);
|
|
663
|
-
}
|
|
664
|
-
visiting.delete(plugin2.id);
|
|
665
|
-
visited.add(plugin2.id);
|
|
666
|
-
sorted.push(plugin2);
|
|
667
|
-
}
|
|
668
|
-
__name(visit, "visit");
|
|
669
|
-
for (const plugin2 of plugins) visit(plugin2);
|
|
670
|
-
return sorted;
|
|
437
|
+
__name(generatePositionalArgsUsage, "generatePositionalArgsUsage");
|
|
438
|
+
function generatePositionalSymbols(args) {
|
|
439
|
+
return hasPositionalArgs(args) ? getPositionalArgs(args).map(([name, arg]) => {
|
|
440
|
+
const elements = [];
|
|
441
|
+
if (!arg.multiple || arg.required) elements.push(`<${name}>`);
|
|
442
|
+
if (arg.multiple) elements.push(`[<${name}> ...]`);
|
|
443
|
+
return elements.join(" ");
|
|
444
|
+
}).join(" ") : "";
|
|
671
445
|
}
|
|
672
|
-
__name(
|
|
673
|
-
|
|
674
|
-
const
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
446
|
+
__name(generatePositionalSymbols, "generatePositionalSymbols");
|
|
447
|
+
function renderValidationErrors(_ctx, error) {
|
|
448
|
+
const messages = [];
|
|
449
|
+
for (const err of error.errors) messages.push(err.message);
|
|
450
|
+
return Promise.resolve(messages.join("\n"));
|
|
451
|
+
}
|
|
452
|
+
__name(renderValidationErrors, "renderValidationErrors");
|
|
453
|
+
var i18nPluginId = namespacedId("i18n");
|
|
454
|
+
var dependencies = [{
|
|
455
|
+
id: i18nPluginId,
|
|
456
|
+
optional: true
|
|
457
|
+
}];
|
|
458
|
+
function renderer() {
|
|
459
|
+
return plugin({
|
|
460
|
+
id: pluginId,
|
|
461
|
+
name: "usage renderer",
|
|
462
|
+
dependencies,
|
|
463
|
+
extension: /* @__PURE__ */ __name((ctx, cmd) => {
|
|
464
|
+
const i18n = ctx.extensions[i18nPluginId];
|
|
465
|
+
let cachedCommands;
|
|
466
|
+
async function loadCommands() {
|
|
467
|
+
if (cachedCommands) return cachedCommands;
|
|
468
|
+
const subCommands = [...ctx.env.subCommands || []];
|
|
469
|
+
cachedCommands = (await Promise.all(subCommands.map(async ([name, cmd2]) => await resolveLazyCommand(cmd2, name)))).filter((cmd2) => !cmd2.internal).filter(Boolean);
|
|
470
|
+
cachedCommands.sort((a, b) => {
|
|
471
|
+
if (a.entry && !b.entry) return -1;
|
|
472
|
+
if (!a.entry && b.entry) return 1;
|
|
473
|
+
if (a.name && b.name) return a.name.localeCompare(b.name);
|
|
474
|
+
if (a.name && !b.name) return -1;
|
|
475
|
+
if (!a.name && b.name) return 1;
|
|
476
|
+
return 0;
|
|
477
|
+
});
|
|
478
|
+
return cachedCommands;
|
|
479
|
+
}
|
|
480
|
+
__name(loadCommands, "loadCommands");
|
|
481
|
+
return {
|
|
482
|
+
text: localizable(ctx, cmd, i18n?.translate),
|
|
483
|
+
loadCommands
|
|
484
|
+
};
|
|
485
|
+
}, "extension"),
|
|
486
|
+
setup: /* @__PURE__ */ __name((ctx) => {
|
|
487
|
+
ctx.decorateHeaderRenderer(async (_baseRenderer, cmdCtx) => await renderHeader(cmdCtx));
|
|
488
|
+
ctx.decorateUsageRenderer(async (_baseRenderer, cmdCtx) => await renderUsage(cmdCtx));
|
|
489
|
+
ctx.decorateValidationErrorsRenderer(async (_baseRenderer, cmdCtx, error) => await renderValidationErrors(cmdCtx, error));
|
|
490
|
+
}, "setup")
|
|
688
491
|
});
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
492
|
+
}
|
|
493
|
+
__name(renderer, "renderer");
|
|
494
|
+
|
|
495
|
+
// ../../node_modules/.bun/gunshi@0.32.0/node_modules/gunshi/lib/context.js
|
|
496
|
+
async function createCommandContext({ args = {}, explicit = {}, values = {}, positionals = [], rest = [], argv = [], tokens = [], command = {}, extensions = {}, cliOptions = {}, callMode = "entry", commandPath = [], omitted = false, validationError }) {
|
|
497
|
+
const _args = Object.entries(args).reduce((acc, [key, value]) => {
|
|
498
|
+
acc[key] = Object.assign(create(), value);
|
|
499
|
+
return acc;
|
|
500
|
+
}, create());
|
|
501
|
+
const env = Object.assign(create(), CLI_OPTIONS_DEFAULT, cliOptions);
|
|
502
|
+
if (command.rendering) {
|
|
503
|
+
const { header, usage, validationErrors } = command.rendering;
|
|
504
|
+
if (header !== void 0) env.renderHeader = header;
|
|
505
|
+
if (usage !== void 0) env.renderUsage = usage;
|
|
506
|
+
if (validationErrors !== void 0) env.renderValidationErrors = validationErrors;
|
|
507
|
+
}
|
|
508
|
+
const core = Object.assign(create(), {
|
|
509
|
+
name: getCommandName(command),
|
|
510
|
+
description: command.description,
|
|
511
|
+
omitted,
|
|
512
|
+
callMode,
|
|
513
|
+
commandPath,
|
|
514
|
+
env,
|
|
515
|
+
args: _args,
|
|
694
516
|
explicit,
|
|
695
517
|
values,
|
|
696
518
|
positionals,
|
|
697
519
|
rest,
|
|
698
|
-
argv,
|
|
520
|
+
_: argv,
|
|
699
521
|
tokens,
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
await
|
|
715
|
-
} catch (error) {
|
|
716
|
-
console.error("Error loading plugin:", error.message);
|
|
717
|
-
}
|
|
718
|
-
return sortedPlugins;
|
|
719
|
-
}
|
|
720
|
-
__name(applyPlugins, "applyPlugins");
|
|
721
|
-
function getCommandArgs(cmd) {
|
|
722
|
-
if (isLazyCommand(cmd)) return cmd.args || create();
|
|
723
|
-
else if (typeof cmd === "object") return cmd.args || create();
|
|
724
|
-
else return create();
|
|
725
|
-
}
|
|
726
|
-
__name(getCommandArgs, "getCommandArgs");
|
|
727
|
-
function resolveArguments(pluginContext, args) {
|
|
728
|
-
return Object.assign(create(), Object.fromEntries(pluginContext.globalOptions), args);
|
|
729
|
-
}
|
|
730
|
-
__name(resolveArguments, "resolveArguments");
|
|
731
|
-
var isObject = /* @__PURE__ */ __name((val) => val !== null && typeof val === "object", "isObject");
|
|
732
|
-
function createInitialSubCommands(options, entryCmd) {
|
|
733
|
-
const hasSubCommands = options.subCommands ? options.subCommands instanceof Map ? options.subCommands.size > 0 : isObject(options.subCommands) && Object.keys(options.subCommands).length > 0 : false;
|
|
734
|
-
const subCommands = new Map(options.subCommands instanceof Map ? options.subCommands : []);
|
|
735
|
-
if (!(options.subCommands instanceof Map) && isObject(options.subCommands)) for (const [name, cmd] of Object.entries(options.subCommands)) subCommands.set(name, cmd);
|
|
736
|
-
if (hasSubCommands) {
|
|
737
|
-
if (isLazyCommand(entryCmd)) {
|
|
738
|
-
const entryCopy = Object.assign((...args) => entryCmd(...args), entryCmd, { entry: true });
|
|
739
|
-
subCommands.set(resolveEntryName(entryCopy), entryCopy);
|
|
740
|
-
} else if (typeof entryCmd === "object") {
|
|
741
|
-
const entryCopy = Object.assign(create(), entryCmd, { entry: true });
|
|
742
|
-
subCommands.set(resolveEntryName(entryCopy), entryCopy);
|
|
743
|
-
} else if (typeof entryCmd === "function") {
|
|
744
|
-
const name = entryCmd.name || ANONYMOUS_COMMAND_NAME;
|
|
745
|
-
subCommands.set(name, {
|
|
746
|
-
run: entryCmd,
|
|
747
|
-
name,
|
|
748
|
-
entry: true
|
|
749
|
-
});
|
|
522
|
+
toKebab: command.toKebab,
|
|
523
|
+
log: cliOptions.usageSilent ? NOOP : log,
|
|
524
|
+
validationError
|
|
525
|
+
});
|
|
526
|
+
if (Object.keys(extensions).length > 0) {
|
|
527
|
+
const ext = create(null);
|
|
528
|
+
Object.defineProperty(core, "extensions", {
|
|
529
|
+
value: ext,
|
|
530
|
+
writable: false,
|
|
531
|
+
enumerable: true,
|
|
532
|
+
configurable: true
|
|
533
|
+
});
|
|
534
|
+
for (const [key, extension2] of Object.entries(extensions)) {
|
|
535
|
+
ext[key] = await extension2.factory(core, command);
|
|
536
|
+
if (extension2.onFactory) await extension2.onFactory(core, command);
|
|
750
537
|
}
|
|
751
538
|
}
|
|
752
|
-
return
|
|
753
|
-
}
|
|
754
|
-
__name(createInitialSubCommands, "createInitialSubCommands");
|
|
755
|
-
function normalizeCliOptions(options, decorators, pluginContext) {
|
|
756
|
-
const subCommands = new Map(pluginContext.subCommands);
|
|
757
|
-
const resolvedOptions = Object.assign(create(), CLI_OPTIONS_DEFAULT, options, { subCommands });
|
|
758
|
-
if (resolvedOptions.renderHeader === void 0) resolvedOptions.renderHeader = decorators.getHeaderRenderer();
|
|
759
|
-
if (resolvedOptions.renderUsage === void 0) resolvedOptions.renderUsage = decorators.getUsageRenderer();
|
|
760
|
-
if (resolvedOptions.renderValidationErrors === void 0) resolvedOptions.renderValidationErrors = decorators.getValidationErrorsRenderer();
|
|
761
|
-
return resolvedOptions;
|
|
539
|
+
return deepFreeze(core, ["extensions"]);
|
|
762
540
|
}
|
|
763
|
-
__name(
|
|
764
|
-
function
|
|
765
|
-
|
|
541
|
+
__name(createCommandContext, "createCommandContext");
|
|
542
|
+
function getCommandName(cmd) {
|
|
543
|
+
if (isLazyCommand(cmd)) return cmd.commandName || cmd.name || "(anonymous)";
|
|
544
|
+
else if (typeof cmd === "object") return cmd.name || "(anonymous)";
|
|
545
|
+
else return ANONYMOUS_COMMAND_NAME;
|
|
766
546
|
}
|
|
767
|
-
__name(
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
depth: 0,
|
|
797
|
-
omitted: options.subCommands.size > 0 && !positionals[0],
|
|
798
|
-
levelSubCommands: options.subCommands.size > 0 ? options.subCommands : void 0
|
|
799
|
-
};
|
|
800
|
-
else return {
|
|
801
|
-
callMode: "unexpected",
|
|
802
|
-
commandPath: [],
|
|
803
|
-
depth: 0,
|
|
804
|
-
omitted: false,
|
|
805
|
-
levelSubCommands: void 0
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
__name(resolveAsEntry, "resolveAsEntry");
|
|
809
|
-
if (positionals.length === 0 || options.subCommands.size === 0) return resolveAsEntry();
|
|
810
|
-
let currentSubCommands = options.subCommands;
|
|
811
|
-
let resolvedCommand;
|
|
812
|
-
let resolvedName;
|
|
813
|
-
const commandPath = [];
|
|
814
|
-
let depth = 0;
|
|
815
|
-
for (let i = 0; i < positionals.length; i++) {
|
|
816
|
-
const token = positionals[i];
|
|
817
|
-
const cmd = currentSubCommands.get(token);
|
|
818
|
-
if (cmd == null) {
|
|
819
|
-
if (depth === 0) {
|
|
820
|
-
if (options.fallbackToEntry) return resolveAsEntry();
|
|
547
|
+
__name(getCommandName, "getCommandName");
|
|
548
|
+
|
|
549
|
+
// ../../node_modules/.bun/gunshi@0.32.0/node_modules/gunshi/lib/core-BKtZQ6dG.js
|
|
550
|
+
var HYPHEN_CHAR = "-";
|
|
551
|
+
var HYPHEN_CODE = HYPHEN_CHAR.codePointAt(0);
|
|
552
|
+
var EQUAL_CHAR = "=";
|
|
553
|
+
var EQUAL_CODE = EQUAL_CHAR.codePointAt(0);
|
|
554
|
+
var TERMINATOR = "--";
|
|
555
|
+
var SHORT_OPTION_PREFIX = HYPHEN_CHAR;
|
|
556
|
+
var LONG_OPTION_PREFIX = "--";
|
|
557
|
+
function parseArgs(args, options = {}) {
|
|
558
|
+
const { allowCompatible = false } = options;
|
|
559
|
+
const tokens = [];
|
|
560
|
+
const remainings = [...args];
|
|
561
|
+
let index = -1;
|
|
562
|
+
let groupCount = 0;
|
|
563
|
+
let hasShortValueSeparator = false;
|
|
564
|
+
while (remainings.length > 0) {
|
|
565
|
+
const arg = remainings.shift();
|
|
566
|
+
if (arg == void 0) break;
|
|
567
|
+
const nextArg = remainings[0];
|
|
568
|
+
if (groupCount > 0) groupCount--;
|
|
569
|
+
else index++;
|
|
570
|
+
if (arg === TERMINATOR) {
|
|
571
|
+
tokens.push({
|
|
572
|
+
kind: "option-terminator",
|
|
573
|
+
index
|
|
574
|
+
});
|
|
575
|
+
const mapped = remainings.map((arg2) => {
|
|
821
576
|
return {
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
depth: 0,
|
|
826
|
-
omitted: false,
|
|
827
|
-
levelSubCommands: void 0
|
|
577
|
+
kind: "positional",
|
|
578
|
+
index: ++index,
|
|
579
|
+
value: arg2
|
|
828
580
|
};
|
|
581
|
+
});
|
|
582
|
+
tokens.push(...mapped);
|
|
583
|
+
break;
|
|
584
|
+
}
|
|
585
|
+
if (isShortOption(arg)) {
|
|
586
|
+
const shortOption = arg.charAt(1);
|
|
587
|
+
let value;
|
|
588
|
+
let inlineValue;
|
|
589
|
+
if (groupCount) {
|
|
590
|
+
tokens.push({
|
|
591
|
+
kind: "option",
|
|
592
|
+
name: shortOption,
|
|
593
|
+
rawName: arg,
|
|
594
|
+
index,
|
|
595
|
+
value,
|
|
596
|
+
inlineValue
|
|
597
|
+
});
|
|
598
|
+
if (groupCount === 1 && hasOptionValue(nextArg)) {
|
|
599
|
+
value = remainings.shift();
|
|
600
|
+
if (hasShortValueSeparator) {
|
|
601
|
+
inlineValue = true;
|
|
602
|
+
hasShortValueSeparator = false;
|
|
603
|
+
}
|
|
604
|
+
tokens.push({
|
|
605
|
+
kind: "option",
|
|
606
|
+
index,
|
|
607
|
+
value,
|
|
608
|
+
inlineValue
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
} else tokens.push({
|
|
612
|
+
kind: "option",
|
|
613
|
+
name: shortOption,
|
|
614
|
+
rawName: arg,
|
|
615
|
+
index,
|
|
616
|
+
value,
|
|
617
|
+
inlineValue
|
|
618
|
+
});
|
|
619
|
+
if (value != null) ++index;
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
if (isShortOptionGroup(arg)) {
|
|
623
|
+
const expanded = [];
|
|
624
|
+
let shortValue = "";
|
|
625
|
+
for (let i = 1; i < arg.length; i++) {
|
|
626
|
+
const shortableOption = arg.charAt(i);
|
|
627
|
+
if (hasShortValueSeparator) shortValue += shortableOption;
|
|
628
|
+
else if (!allowCompatible && shortableOption.codePointAt(0) === EQUAL_CODE) hasShortValueSeparator = true;
|
|
629
|
+
else expanded.push(`${SHORT_OPTION_PREFIX}${shortableOption}`);
|
|
829
630
|
}
|
|
830
|
-
|
|
631
|
+
if (shortValue) expanded.push(shortValue);
|
|
632
|
+
remainings.unshift(...expanded);
|
|
633
|
+
groupCount = expanded.length;
|
|
634
|
+
continue;
|
|
831
635
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
636
|
+
if (isLongOption(arg)) {
|
|
637
|
+
const longOption = arg.slice(2);
|
|
638
|
+
tokens.push({
|
|
639
|
+
kind: "option",
|
|
640
|
+
name: longOption,
|
|
641
|
+
rawName: arg,
|
|
642
|
+
index,
|
|
643
|
+
value: void 0,
|
|
644
|
+
inlineValue: void 0
|
|
645
|
+
});
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
if (isLongOptionAndValue(arg)) {
|
|
649
|
+
const equalIndex = arg.indexOf(EQUAL_CHAR);
|
|
650
|
+
const longOption = arg.slice(2, equalIndex);
|
|
651
|
+
const value = arg.slice(equalIndex + 1);
|
|
652
|
+
tokens.push({
|
|
653
|
+
kind: "option",
|
|
654
|
+
name: longOption,
|
|
655
|
+
rawName: `${LONG_OPTION_PREFIX}${longOption}`,
|
|
656
|
+
index,
|
|
657
|
+
value,
|
|
658
|
+
inlineValue: true
|
|
659
|
+
});
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
662
|
+
tokens.push({
|
|
663
|
+
kind: "positional",
|
|
664
|
+
index,
|
|
665
|
+
value: arg
|
|
666
|
+
});
|
|
853
667
|
}
|
|
854
|
-
return
|
|
855
|
-
commandName: resolvedName,
|
|
856
|
-
command: resolvedCommand,
|
|
857
|
-
callMode: depth > 0 ? "subCommand" : "entry",
|
|
858
|
-
commandPath,
|
|
859
|
-
depth,
|
|
860
|
-
omitted,
|
|
861
|
-
levelSubCommands
|
|
862
|
-
};
|
|
668
|
+
return tokens;
|
|
863
669
|
}
|
|
864
|
-
__name(
|
|
865
|
-
function
|
|
866
|
-
return
|
|
670
|
+
__name(parseArgs, "parseArgs");
|
|
671
|
+
function isShortOption(arg) {
|
|
672
|
+
return arg.length === 2 && arg.codePointAt(0) === HYPHEN_CODE && arg.codePointAt(1) !== HYPHEN_CODE;
|
|
867
673
|
}
|
|
868
|
-
__name(
|
|
869
|
-
function
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
else extensions[key] = plugin2.extension;
|
|
875
|
-
}
|
|
876
|
-
return extensions;
|
|
674
|
+
__name(isShortOption, "isShortOption");
|
|
675
|
+
function isShortOptionGroup(arg) {
|
|
676
|
+
if (arg.length <= 2) return false;
|
|
677
|
+
if (arg.codePointAt(0) !== HYPHEN_CODE) return false;
|
|
678
|
+
if (arg.codePointAt(1) === HYPHEN_CODE) return false;
|
|
679
|
+
return true;
|
|
877
680
|
}
|
|
878
|
-
__name(
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
const decoratedRunner = decorators.reduceRight((runner, decorator2) => decorator2(runner), baseRunner);
|
|
882
|
-
try {
|
|
883
|
-
if (ctx.env.onBeforeCommand) await ctx.env.onBeforeCommand(ctx);
|
|
884
|
-
const result = await decoratedRunner(ctx);
|
|
885
|
-
if (ctx.env.onAfterCommand) await ctx.env.onAfterCommand(ctx, result);
|
|
886
|
-
return typeof result === "string" ? result : void 0;
|
|
887
|
-
} catch (error) {
|
|
888
|
-
if (ctx.env.onErrorCommand) try {
|
|
889
|
-
await ctx.env.onErrorCommand(ctx, error);
|
|
890
|
-
} catch (hookError) {
|
|
891
|
-
console.error("Error in onErrorCommand hook:", hookError);
|
|
892
|
-
}
|
|
893
|
-
throw error;
|
|
894
|
-
}
|
|
681
|
+
__name(isShortOptionGroup, "isShortOptionGroup");
|
|
682
|
+
function isLongOption(arg) {
|
|
683
|
+
return hasLongOptionPrefix(arg) && !arg.includes(EQUAL_CHAR, 3);
|
|
895
684
|
}
|
|
896
|
-
__name(
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
var NOOP_EXTENSION = /* @__PURE__ */ __name(() => {
|
|
900
|
-
return /* @__PURE__ */ Object.create(null);
|
|
901
|
-
}, "NOOP_EXTENSION");
|
|
902
|
-
function plugin(options = {}) {
|
|
903
|
-
const { id, name, setup, onExtension, dependencies: dependencies2 } = options;
|
|
904
|
-
const extension2 = options.extension || NOOP_EXTENSION;
|
|
905
|
-
const pluginFn = /* @__PURE__ */ __name(async (ctx) => {
|
|
906
|
-
if (setup) await setup(ctx);
|
|
907
|
-
}, "pluginFn");
|
|
908
|
-
const props = {
|
|
909
|
-
writable: false,
|
|
910
|
-
enumerable: true,
|
|
911
|
-
configurable: true
|
|
912
|
-
};
|
|
913
|
-
return Object.defineProperties(pluginFn, {
|
|
914
|
-
id: {
|
|
915
|
-
value: id,
|
|
916
|
-
...props
|
|
917
|
-
},
|
|
918
|
-
...name && { name: {
|
|
919
|
-
value: name,
|
|
920
|
-
...props
|
|
921
|
-
} },
|
|
922
|
-
...dependencies2 && { dependencies: {
|
|
923
|
-
value: dependencies2,
|
|
924
|
-
...props
|
|
925
|
-
} },
|
|
926
|
-
...extension2 && { extension: {
|
|
927
|
-
value: {
|
|
928
|
-
key: Symbol(id),
|
|
929
|
-
factory: extension2,
|
|
930
|
-
onFactory: onExtension
|
|
931
|
-
},
|
|
932
|
-
...props
|
|
933
|
-
} }
|
|
934
|
-
});
|
|
685
|
+
__name(isLongOption, "isLongOption");
|
|
686
|
+
function isLongOptionAndValue(arg) {
|
|
687
|
+
return hasLongOptionPrefix(arg) && arg.includes(EQUAL_CHAR, 3);
|
|
935
688
|
}
|
|
936
|
-
__name(
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
var
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
689
|
+
__name(isLongOptionAndValue, "isLongOptionAndValue");
|
|
690
|
+
function hasLongOptionPrefix(arg) {
|
|
691
|
+
return arg.startsWith(LONG_OPTION_PREFIX) && arg.length > 2;
|
|
692
|
+
}
|
|
693
|
+
__name(hasLongOptionPrefix, "hasLongOptionPrefix");
|
|
694
|
+
function hasOptionValue(value) {
|
|
695
|
+
return !(value == null) && value.codePointAt(0) !== HYPHEN_CODE;
|
|
696
|
+
}
|
|
697
|
+
__name(hasOptionValue, "hasOptionValue");
|
|
698
|
+
var SKIP_POSITIONAL_DEFAULT = -1;
|
|
699
|
+
function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKIP_POSITIONAL_DEFAULT, toKebab = false } = {}) {
|
|
700
|
+
const skipPositionalIndex = typeof skipPositional === "number" ? Math.max(skipPositional, SKIP_POSITIONAL_DEFAULT) : SKIP_POSITIONAL_DEFAULT;
|
|
701
|
+
const rest = [];
|
|
702
|
+
const optionTokens = [];
|
|
703
|
+
const positionalTokens = [];
|
|
704
|
+
let currentLongOption;
|
|
705
|
+
let currentShortOption;
|
|
706
|
+
const expandableShortOptions = [];
|
|
707
|
+
function toShortValue() {
|
|
708
|
+
if (expandableShortOptions.length === 0) return;
|
|
709
|
+
else {
|
|
710
|
+
const value = expandableShortOptions.map((token) => token.name).join("");
|
|
711
|
+
expandableShortOptions.length = 0;
|
|
712
|
+
return value;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
__name(toShortValue, "toShortValue");
|
|
716
|
+
function applyLongOptionValue(value) {
|
|
717
|
+
if (currentLongOption) {
|
|
718
|
+
currentLongOption.value = value;
|
|
719
|
+
optionTokens.push({ ...currentLongOption });
|
|
720
|
+
currentLongOption = void 0;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
__name(applyLongOptionValue, "applyLongOptionValue");
|
|
724
|
+
function applyShortOptionValue(value) {
|
|
725
|
+
if (currentShortOption) {
|
|
726
|
+
currentShortOption.value = value || toShortValue();
|
|
727
|
+
optionTokens.push({ ...currentShortOption });
|
|
728
|
+
currentShortOption = void 0;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
__name(applyShortOptionValue, "applyShortOptionValue");
|
|
732
|
+
const schemas = Object.values(args);
|
|
733
|
+
let terminated = false;
|
|
734
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
735
|
+
const token = tokens[i];
|
|
736
|
+
if (token.kind === "positional") {
|
|
737
|
+
if (terminated && token.value) {
|
|
738
|
+
rest.push(token.value);
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
if (currentShortOption) if (schemas.find((schema) => schema.short === currentShortOption.name && schema.type === "boolean")) {
|
|
742
|
+
positionalTokens.push({ ...token });
|
|
743
|
+
applyShortOptionValue();
|
|
744
|
+
} else applyShortOptionValue(token.value);
|
|
745
|
+
else if (currentLongOption) if (args[currentLongOption.name]?.type === "boolean") {
|
|
746
|
+
positionalTokens.push({ ...token });
|
|
747
|
+
applyLongOptionValue();
|
|
748
|
+
} else applyLongOptionValue(token.value);
|
|
749
|
+
else positionalTokens.push({ ...token });
|
|
750
|
+
} else if (token.kind === "option") if (token.rawName) {
|
|
751
|
+
if (hasLongOptionPrefix(token.rawName)) {
|
|
752
|
+
applyLongOptionValue();
|
|
753
|
+
if (token.inlineValue) optionTokens.push({ ...token });
|
|
754
|
+
else currentLongOption = { ...token };
|
|
755
|
+
applyShortOptionValue();
|
|
756
|
+
} else if (isShortOption(token.rawName)) if (currentShortOption) {
|
|
757
|
+
if (currentShortOption.index === token.index) if (shortGrouping) {
|
|
758
|
+
currentShortOption.value = token.value;
|
|
759
|
+
optionTokens.push({ ...currentShortOption });
|
|
760
|
+
currentShortOption = { ...token };
|
|
761
|
+
} else expandableShortOptions.push({ ...token });
|
|
762
|
+
else {
|
|
763
|
+
currentShortOption.value = toShortValue();
|
|
764
|
+
optionTokens.push({ ...currentShortOption });
|
|
765
|
+
currentShortOption = { ...token };
|
|
766
|
+
}
|
|
767
|
+
applyLongOptionValue();
|
|
768
|
+
} else {
|
|
769
|
+
currentShortOption = { ...token };
|
|
770
|
+
applyLongOptionValue();
|
|
771
|
+
}
|
|
772
|
+
} else {
|
|
773
|
+
if (currentShortOption && currentShortOption.index == token.index && token.inlineValue) {
|
|
774
|
+
currentShortOption.value = token.value;
|
|
775
|
+
optionTokens.push({ ...currentShortOption });
|
|
776
|
+
currentShortOption = void 0;
|
|
777
|
+
}
|
|
778
|
+
applyLongOptionValue();
|
|
779
|
+
}
|
|
780
|
+
else {
|
|
781
|
+
if (token.kind === "option-terminator") terminated = true;
|
|
782
|
+
applyLongOptionValue();
|
|
783
|
+
applyShortOptionValue();
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
applyLongOptionValue();
|
|
787
|
+
applyShortOptionValue();
|
|
788
|
+
const values = /* @__PURE__ */ Object.create(null);
|
|
789
|
+
const errors = [];
|
|
790
|
+
const explicit = /* @__PURE__ */ Object.create(null);
|
|
791
|
+
const actualInputNames = /* @__PURE__ */ new Map();
|
|
792
|
+
function checkTokenName(option, schema, token) {
|
|
793
|
+
return token.name === (schema.type === "boolean" ? schema.negatable && token.name?.startsWith("no-") ? `no-${option}` : option : option);
|
|
956
794
|
}
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
if (schema.short) key = `-${schema.short}, ${key}`;
|
|
997
|
-
return key;
|
|
998
|
-
}
|
|
999
|
-
__name(makeShortLongOptionPair, "makeShortLongOptionPair");
|
|
1000
|
-
function localizable(ctx, cmd, translate) {
|
|
1001
|
-
async function localize(key, values) {
|
|
1002
|
-
if (translate) return translate(key, values);
|
|
1003
|
-
if (key.startsWith(BUILD_IN_PREFIX_AND_KEY_SEPARATOR)) return en_US_default[key.slice(BUILD_IN_PREFIX_AND_KEY_SEPARATOR.length)] || key;
|
|
1004
|
-
const namaspacedArgKey = resolveKey(ARG_PREFIX_AND_KEY_SEPARATOR, ctx.name);
|
|
1005
|
-
if (key.startsWith(namaspacedArgKey)) {
|
|
1006
|
-
let argKey = key.slice(namaspacedArgKey.length);
|
|
1007
|
-
let negatable = false;
|
|
1008
|
-
if (argKey.startsWith(ARG_NEGATABLE_PREFIX)) {
|
|
1009
|
-
argKey = argKey.slice(ARG_NEGATABLE_PREFIX.length);
|
|
1010
|
-
negatable = true;
|
|
795
|
+
__name(checkTokenName, "checkTokenName");
|
|
796
|
+
const positionalItemCount = tokens.filter((token) => token.kind === "positional").length;
|
|
797
|
+
function getPositionalSkipIndex() {
|
|
798
|
+
return Math.min(skipPositionalIndex, positionalItemCount);
|
|
799
|
+
}
|
|
800
|
+
__name(getPositionalSkipIndex, "getPositionalSkipIndex");
|
|
801
|
+
let positionalsCount = 0;
|
|
802
|
+
for (const [rawArg, schema] of Object.entries(args)) {
|
|
803
|
+
const arg = toKebab || schema.toKebab ? kebabnize(rawArg) : rawArg;
|
|
804
|
+
explicit[rawArg] = false;
|
|
805
|
+
if (schema.type === "positional") {
|
|
806
|
+
if (skipPositionalIndex > SKIP_POSITIONAL_DEFAULT) while (positionalsCount <= getPositionalSkipIndex()) positionalsCount++;
|
|
807
|
+
if (schema.multiple) {
|
|
808
|
+
const remainingPositionals = positionalTokens.slice(positionalsCount);
|
|
809
|
+
if (remainingPositionals.length > 0) {
|
|
810
|
+
if (typeof schema.parse === "function") {
|
|
811
|
+
const parsed = [];
|
|
812
|
+
for (const p of remainingPositionals) try {
|
|
813
|
+
parsed.push(schema.parse(p.value));
|
|
814
|
+
} catch (error) {
|
|
815
|
+
errors.push(error);
|
|
816
|
+
}
|
|
817
|
+
values[rawArg] = parsed;
|
|
818
|
+
} else values[rawArg] = remainingPositionals.map((p) => p.value);
|
|
819
|
+
positionalsCount += remainingPositionals.length;
|
|
820
|
+
explicit[rawArg] = true;
|
|
821
|
+
} else if (schema.required) errors.push(createRequireError(arg, schema));
|
|
822
|
+
} else {
|
|
823
|
+
const positional = positionalTokens[positionalsCount];
|
|
824
|
+
if (positional != null) {
|
|
825
|
+
if (typeof schema.parse === "function") try {
|
|
826
|
+
values[rawArg] = schema.parse(positional.value);
|
|
827
|
+
} catch (error) {
|
|
828
|
+
errors.push(error);
|
|
829
|
+
}
|
|
830
|
+
else values[rawArg] = positional.value;
|
|
831
|
+
explicit[rawArg] = true;
|
|
832
|
+
} else errors.push(createRequireError(arg, schema));
|
|
833
|
+
positionalsCount++;
|
|
1011
834
|
}
|
|
1012
|
-
|
|
1013
|
-
if (!schema) return argKey;
|
|
1014
|
-
return negatable && schema.type === "boolean" && schema.negatable ? `${NEGATABLE} ${makeShortLongOptionPair(schema, argKey, ctx.toKebab)}` : schema.description || "";
|
|
835
|
+
continue;
|
|
1015
836
|
}
|
|
1016
|
-
if (
|
|
1017
|
-
|
|
1018
|
-
|
|
837
|
+
if (schema.required) {
|
|
838
|
+
if (!optionTokens.find((token) => {
|
|
839
|
+
return schema.short && token.name === schema.short || token.rawName && hasLongOptionPrefix(token.rawName) && token.name === arg;
|
|
840
|
+
})) {
|
|
841
|
+
errors.push(createRequireError(arg, schema));
|
|
842
|
+
continue;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
for (let i = 0; i < optionTokens.length; i++) {
|
|
846
|
+
const token = optionTokens[i];
|
|
847
|
+
if (checkTokenName(arg, schema, token) && token.rawName != void 0 && hasLongOptionPrefix(token.rawName) || schema.short === token.name && token.rawName != void 0 && isShortOption(token.rawName)) {
|
|
848
|
+
const invalid = validateRequire(token, arg, schema);
|
|
849
|
+
if (invalid) {
|
|
850
|
+
errors.push(invalid);
|
|
851
|
+
continue;
|
|
852
|
+
}
|
|
853
|
+
explicit[rawArg] = true;
|
|
854
|
+
const actualInputName = isShortOption(token.rawName) ? `-${token.name}` : `--${arg}`;
|
|
855
|
+
actualInputNames.set(rawArg, actualInputName);
|
|
856
|
+
const [parsedValue, error] = parse(token, arg, schema);
|
|
857
|
+
if (error) errors.push(error);
|
|
858
|
+
else if (schema.multiple) {
|
|
859
|
+
values[rawArg] ||= [];
|
|
860
|
+
values[rawArg].push(parsedValue);
|
|
861
|
+
} else values[rawArg] = parsedValue;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
if (values[rawArg] == null && schema.default != null) values[rawArg] = schema.default;
|
|
1019
865
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
866
|
+
const conflictErrors = checkConflicts(args, explicit, toKebab, actualInputNames);
|
|
867
|
+
errors.push(...conflictErrors);
|
|
868
|
+
return {
|
|
869
|
+
values,
|
|
870
|
+
positionals: positionalTokens.map((token) => token.value),
|
|
871
|
+
rest,
|
|
872
|
+
error: errors.length > 0 ? new AggregateError(errors) : void 0,
|
|
873
|
+
explicit
|
|
874
|
+
};
|
|
1027
875
|
}
|
|
1028
|
-
__name(
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
876
|
+
__name(resolveArgs, "resolveArgs");
|
|
877
|
+
function parse(token, option, schema) {
|
|
878
|
+
if (typeof schema.parse === "function") try {
|
|
879
|
+
if (schema.type === "boolean") {
|
|
880
|
+
const boolValue = !(schema.negatable && token.name.startsWith("no-"));
|
|
881
|
+
return [schema.parse(String(boolValue)), void 0];
|
|
882
|
+
}
|
|
883
|
+
return [schema.parse(token.value ?? String(schema.default ?? "")), void 0];
|
|
884
|
+
} catch (error) {
|
|
885
|
+
return [void 0, error];
|
|
1036
886
|
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
}
|
|
1052
|
-
__name(renderPositionalArgsSection, "renderPositionalArgsSection");
|
|
1053
|
-
async function renderOptionalArgsSection(ctx) {
|
|
1054
|
-
const messages = [];
|
|
1055
|
-
messages.push(`${await ctx.extensions[pluginId].text(resolveBuiltInKey("OPTIONS"))}:`);
|
|
1056
|
-
messages.push(await generateOptionalArgsUsage(ctx, getOptionalArgsPairs(ctx)));
|
|
1057
|
-
return messages;
|
|
1058
|
-
}
|
|
1059
|
-
__name(renderOptionalArgsSection, "renderOptionalArgsSection");
|
|
1060
|
-
async function renderExamplesSection(ctx) {
|
|
1061
|
-
const messages = [];
|
|
1062
|
-
const resolvedExamples = await resolveExamples(ctx);
|
|
1063
|
-
if (resolvedExamples) {
|
|
1064
|
-
const examples = resolvedExamples.split("\n").map((example) => example.padStart(ctx.env.leftMargin + example.length));
|
|
1065
|
-
messages.push(`${await ctx.extensions[pluginId].text(resolveBuiltInKey("EXAMPLES"))}:`, ...examples);
|
|
887
|
+
switch (schema.type) {
|
|
888
|
+
case "string":
|
|
889
|
+
return typeof token.value === "string" ? [token.value || schema.default, void 0] : [void 0, createTypeError(option, schema)];
|
|
890
|
+
case "boolean":
|
|
891
|
+
return [!(schema.negatable && token.name.startsWith("no-")), void 0];
|
|
892
|
+
case "number":
|
|
893
|
+
if (!isNumeric(token.value)) return [void 0, createTypeError(option, schema)];
|
|
894
|
+
return token.value ? [+token.value, void 0] : [+(schema.default || ""), void 0];
|
|
895
|
+
case "enum":
|
|
896
|
+
if (schema.choices && !schema.choices.includes(token.value)) return [void 0, new ArgResolveError(`Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}should be chosen from '${schema.type}' [${schema.choices.map((c) => JSON.stringify(c)).join(", ")}] values`, option, "type", schema)];
|
|
897
|
+
return [token.value || schema.default, void 0];
|
|
898
|
+
case "custom":
|
|
899
|
+
throw new TypeError(`argument '${option}' should have a 'parse' function`);
|
|
900
|
+
default:
|
|
901
|
+
throw new Error(`Unsupported argument type '${schema.type}' for option '${option}'`);
|
|
1066
902
|
}
|
|
1067
|
-
return messages;
|
|
1068
|
-
}
|
|
1069
|
-
__name(renderExamplesSection, "renderExamplesSection");
|
|
1070
|
-
async function renderUsageSection(ctx) {
|
|
1071
|
-
const messages = [`${await ctx.extensions[pluginId].text(resolveBuiltInKey("USAGE"))}:`];
|
|
1072
|
-
const usageStr = await makeUsageSymbols(ctx);
|
|
1073
|
-
messages.push(usageStr.padStart(ctx.env.leftMargin + usageStr.length));
|
|
1074
|
-
return messages;
|
|
1075
|
-
}
|
|
1076
|
-
__name(renderUsageSection, "renderUsageSection");
|
|
1077
|
-
async function makeUsageSymbols(ctx) {
|
|
1078
|
-
const messages = [await resolveEntry(ctx)];
|
|
1079
|
-
if (ctx.omitted) if (await hasCommands(ctx)) messages.push(` [${await ctx.extensions[pluginId].text(resolveBuiltInKey("COMMANDS"))}]`);
|
|
1080
|
-
else messages.push(`${ctx.callMode === "subCommand" ? ` ${await resolveSubCommand(ctx)}` : ""}`);
|
|
1081
|
-
else messages.push(`${ctx.callMode === "subCommand" ? ` ${await resolveSubCommand(ctx)}` : ""}`);
|
|
1082
|
-
const optionsSymbols = await generateOptionsSymbols(ctx, ctx.args);
|
|
1083
|
-
if (optionsSymbols) messages.push(" ", optionsSymbols);
|
|
1084
|
-
const positionalSymbols = generatePositionalSymbols(ctx.args);
|
|
1085
|
-
if (positionalSymbols) messages.push(" ", positionalSymbols);
|
|
1086
|
-
return messages.join("");
|
|
1087
903
|
}
|
|
1088
|
-
__name(
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
const loadedCommands = await ctx.extensions?.[pluginId].loadCommands() || [];
|
|
1092
|
-
const commandMaxLength = Math.max(...loadedCommands.map((cmd) => (cmd.name || "").length));
|
|
1093
|
-
const commandsStr = await Promise.all(loadedCommands.map(async (cmd) => {
|
|
1094
|
-
const desc = cmd.description || "";
|
|
1095
|
-
const optionSymbol = await generateOptionsSymbols(ctx, ctx.args);
|
|
1096
|
-
const positionalSymbol = generatePositionalSymbols(ctx.args);
|
|
1097
|
-
const commandStr = await makeCommandSymbol(ctx, cmd);
|
|
1098
|
-
const symbolLength = desc.length > 0 ? commandMaxLength + optionSymbol.length + positionalSymbol.length : 0;
|
|
1099
|
-
const command = `${commandStr.padEnd(symbolLength + ctx.env.middleMargin)}${desc}`;
|
|
1100
|
-
return `${command.padStart(ctx.env.leftMargin + command.length)}`;
|
|
1101
|
-
}));
|
|
1102
|
-
messages.push(...commandsStr, "", `${await ctx.extensions[pluginId].text(resolveBuiltInKey("FORMORE"))}:`);
|
|
1103
|
-
const basePath = ctx.commandPath && ctx.commandPath.length > 0 ? `${ctx.env.name} ${ctx.commandPath.join(" ")}` : ctx.env.name;
|
|
1104
|
-
messages.push(...loadedCommands.map((cmd) => {
|
|
1105
|
-
let commandStr = cmd.entry ? "" : cmd.name || "";
|
|
1106
|
-
if (commandStr) commandStr += " ";
|
|
1107
|
-
const commandHelp = `${basePath} ${commandStr}--help`;
|
|
1108
|
-
return `${commandHelp.padStart(ctx.env.leftMargin + commandHelp.length)}`;
|
|
1109
|
-
}));
|
|
1110
|
-
return messages;
|
|
904
|
+
__name(parse, "parse");
|
|
905
|
+
function createRequireError(option, schema) {
|
|
906
|
+
return new ArgResolveError(schema.type === "positional" ? `Positional argument '${option}' is required` : `Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}is required`, option, "required", schema);
|
|
1111
907
|
}
|
|
1112
|
-
__name(
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
let commandStr = cmd.entry ? cmd.name === void 0 || cmd.name === ANONYMOUS_COMMAND_NAME ? "" : `[${cmd.name}]` : cmd.name || "";
|
|
1117
|
-
if (optionSymbol) {
|
|
1118
|
-
if (commandStr) commandStr += " ";
|
|
1119
|
-
commandStr += `${optionSymbol}`;
|
|
908
|
+
__name(createRequireError, "createRequireError");
|
|
909
|
+
var ArgResolveError = class extends Error {
|
|
910
|
+
static {
|
|
911
|
+
__name(this, "ArgResolveError");
|
|
1120
912
|
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
913
|
+
name;
|
|
914
|
+
schema;
|
|
915
|
+
type;
|
|
916
|
+
/**
|
|
917
|
+
* Create an `ArgResolveError` instance.
|
|
918
|
+
*
|
|
919
|
+
* @param message - the error message
|
|
920
|
+
* @param name - the name of the argument
|
|
921
|
+
* @param type - the type of the error, either 'type' or 'required'
|
|
922
|
+
* @param schema - the argument schema that caused the error
|
|
923
|
+
*/
|
|
924
|
+
constructor(message, name, type, schema) {
|
|
925
|
+
super(message);
|
|
926
|
+
this.name = name;
|
|
927
|
+
this.type = type;
|
|
928
|
+
this.schema = schema;
|
|
1124
929
|
}
|
|
1125
|
-
|
|
930
|
+
};
|
|
931
|
+
function validateRequire(token, option, schema) {
|
|
932
|
+
if (schema.required && schema.type !== "boolean" && !token.value) return createRequireError(option, schema);
|
|
1126
933
|
}
|
|
1127
|
-
__name(
|
|
1128
|
-
|
|
1129
|
-
return
|
|
934
|
+
__name(validateRequire, "validateRequire");
|
|
935
|
+
function isNumeric(str) {
|
|
936
|
+
return str.trim() !== "" && !isNaN(str);
|
|
1130
937
|
}
|
|
1131
|
-
__name(
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
return ctx.name || await ctx.extensions[pluginId].text(resolveBuiltInKey("SUBCOMMAND"));
|
|
938
|
+
__name(isNumeric, "isNumeric");
|
|
939
|
+
function createTypeError(option, schema) {
|
|
940
|
+
return new ArgResolveError(`Optional argument '--${option}' ${schema.short ? `or '-${schema.short}' ` : ""}should be '${schema.type}'`, option, "type", schema);
|
|
1135
941
|
}
|
|
1136
|
-
__name(
|
|
1137
|
-
|
|
1138
|
-
|
|
942
|
+
__name(createTypeError, "createTypeError");
|
|
943
|
+
function checkConflicts(args, explicit, toKebab, actualInputNames) {
|
|
944
|
+
for (const rawArg in args) {
|
|
945
|
+
const schema = args[rawArg];
|
|
946
|
+
if (!explicit[rawArg]) continue;
|
|
947
|
+
if (!schema.conflicts) continue;
|
|
948
|
+
const conflicts = Array.isArray(schema.conflicts) ? schema.conflicts : [schema.conflicts];
|
|
949
|
+
for (let i = 0; i < conflicts.length; i++) {
|
|
950
|
+
const conflictingArg = conflicts[i];
|
|
951
|
+
if (!explicit[conflictingArg]) continue;
|
|
952
|
+
const arg = toKebab || schema.toKebab ? kebabnize(rawArg) : rawArg;
|
|
953
|
+
const conflictingArgKebab = toKebab || args[conflictingArg]?.toKebab ? kebabnize(conflictingArg) : conflictingArg;
|
|
954
|
+
return [new ArgResolveError(`Optional argument '${actualInputNames.get(rawArg) || `--${arg}`}' conflicts with '${actualInputNames.get(conflictingArg) || `--${conflictingArgKebab}`}'`, rawArg, "conflict", schema)];
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
return [];
|
|
1139
958
|
}
|
|
1140
|
-
__name(
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
const
|
|
1145
|
-
|
|
959
|
+
__name(checkConflicts, "checkConflicts");
|
|
960
|
+
var EMPTY_RENDERER = /* @__PURE__ */ __name(() => Promise.resolve(""), "EMPTY_RENDERER");
|
|
961
|
+
function createDecorators() {
|
|
962
|
+
const headerDecorators = [];
|
|
963
|
+
const usageDecorators = [];
|
|
964
|
+
const validationDecorators = [];
|
|
965
|
+
const commandDecorators = [];
|
|
966
|
+
function buildRenderer(decorators, defaultRenderer) {
|
|
967
|
+
if (decorators.length === 0) return defaultRenderer;
|
|
968
|
+
let renderer2 = defaultRenderer;
|
|
969
|
+
for (const decorator2 of decorators) {
|
|
970
|
+
const previousRenderer = renderer2;
|
|
971
|
+
renderer2 = /* @__PURE__ */ __name((ctx) => decorator2(previousRenderer, ctx), "renderer");
|
|
972
|
+
}
|
|
973
|
+
return renderer2;
|
|
974
|
+
}
|
|
975
|
+
__name(buildRenderer, "buildRenderer");
|
|
976
|
+
return Object.freeze({
|
|
977
|
+
addHeaderDecorator(decorator2) {
|
|
978
|
+
headerDecorators.push(decorator2);
|
|
979
|
+
},
|
|
980
|
+
addUsageDecorator(decorator2) {
|
|
981
|
+
usageDecorators.push(decorator2);
|
|
982
|
+
},
|
|
983
|
+
addValidationErrorsDecorator(decorator2) {
|
|
984
|
+
validationDecorators.push(decorator2);
|
|
985
|
+
},
|
|
986
|
+
addCommandDecorator(decorator2) {
|
|
987
|
+
commandDecorators.push(decorator2);
|
|
988
|
+
},
|
|
989
|
+
get commandDecorators() {
|
|
990
|
+
return [...commandDecorators];
|
|
991
|
+
},
|
|
992
|
+
getHeaderRenderer() {
|
|
993
|
+
return buildRenderer(headerDecorators, EMPTY_RENDERER);
|
|
994
|
+
},
|
|
995
|
+
getUsageRenderer() {
|
|
996
|
+
return buildRenderer(usageDecorators, EMPTY_RENDERER);
|
|
997
|
+
},
|
|
998
|
+
getValidationErrorsRenderer() {
|
|
999
|
+
if (validationDecorators.length === 0) return EMPTY_RENDERER;
|
|
1000
|
+
let renderer2 = EMPTY_RENDERER;
|
|
1001
|
+
for (const decorator2 of validationDecorators) {
|
|
1002
|
+
const previousRenderer = renderer2;
|
|
1003
|
+
renderer2 = /* @__PURE__ */ __name((ctx, error) => decorator2(previousRenderer, ctx, error), "renderer");
|
|
1004
|
+
}
|
|
1005
|
+
return renderer2;
|
|
1006
|
+
}
|
|
1007
|
+
});
|
|
1146
1008
|
}
|
|
1147
|
-
__name(
|
|
1148
|
-
|
|
1149
|
-
|
|
1009
|
+
__name(createDecorators, "createDecorators");
|
|
1010
|
+
function createPluginContext(decorators, initialSubCommands) {
|
|
1011
|
+
const globalOptions = /* @__PURE__ */ new Map();
|
|
1012
|
+
const subCommands = new Map(initialSubCommands || []);
|
|
1013
|
+
return Object.freeze({
|
|
1014
|
+
get globalOptions() {
|
|
1015
|
+
return new Map(globalOptions);
|
|
1016
|
+
},
|
|
1017
|
+
addGlobalOption(name, schema) {
|
|
1018
|
+
if (!name) throw new Error("Option name must be a non-empty string");
|
|
1019
|
+
if (globalOptions.has(name)) throw new Error(`Global option '${name}' is already registered`);
|
|
1020
|
+
globalOptions.set(name, schema);
|
|
1021
|
+
},
|
|
1022
|
+
get subCommands() {
|
|
1023
|
+
return new Map(subCommands);
|
|
1024
|
+
},
|
|
1025
|
+
addCommand(name, command) {
|
|
1026
|
+
if (!name) throw new Error("Command name must be a non-empty string");
|
|
1027
|
+
if (subCommands.has(name)) throw new Error(`Command '${name}' is already registered`);
|
|
1028
|
+
subCommands.set(name, command);
|
|
1029
|
+
},
|
|
1030
|
+
hasCommand(name) {
|
|
1031
|
+
return subCommands.has(name);
|
|
1032
|
+
},
|
|
1033
|
+
decorateHeaderRenderer(decorator2) {
|
|
1034
|
+
decorators.addHeaderDecorator(decorator2);
|
|
1035
|
+
},
|
|
1036
|
+
decorateUsageRenderer(decorator2) {
|
|
1037
|
+
decorators.addUsageDecorator(decorator2);
|
|
1038
|
+
},
|
|
1039
|
+
decorateValidationErrorsRenderer(decorator2) {
|
|
1040
|
+
decorators.addValidationErrorsDecorator(decorator2);
|
|
1041
|
+
},
|
|
1042
|
+
decorateCommand(decorator2) {
|
|
1043
|
+
decorators.addCommandDecorator(decorator2);
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1150
1046
|
}
|
|
1151
|
-
__name(
|
|
1152
|
-
function
|
|
1153
|
-
|
|
1047
|
+
__name(createPluginContext, "createPluginContext");
|
|
1048
|
+
function resolveDependencies(plugins) {
|
|
1049
|
+
const sorted = [];
|
|
1050
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1051
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
1052
|
+
const pluginMap = /* @__PURE__ */ new Map();
|
|
1053
|
+
for (const plugin2 of plugins) if (plugin2.id) {
|
|
1054
|
+
if (pluginMap.has(plugin2.id)) console.warn(`Duplicate plugin id detected: \`${plugin2.id}\``);
|
|
1055
|
+
pluginMap.set(plugin2.id, plugin2);
|
|
1056
|
+
}
|
|
1057
|
+
function visit(plugin2) {
|
|
1058
|
+
if (!plugin2.id) return;
|
|
1059
|
+
if (visited.has(plugin2.id)) return;
|
|
1060
|
+
if (visiting.has(plugin2.id)) throw new Error(`Circular dependency detected: \`${[...visiting].join(` -> `) + " -> " + plugin2.id}\``);
|
|
1061
|
+
visiting.add(plugin2.id);
|
|
1062
|
+
const deps = plugin2.dependencies || [];
|
|
1063
|
+
for (const dep of deps) {
|
|
1064
|
+
const depId = typeof dep === "string" ? dep : dep.id;
|
|
1065
|
+
const isOptional = typeof dep === "string" ? false : dep.optional || false;
|
|
1066
|
+
const depPlugin = pluginMap.get(depId);
|
|
1067
|
+
if (!depPlugin && !isOptional) throw new Error(`Missing required dependency: \`${depId}\` on \`${plugin2.id}\``);
|
|
1068
|
+
if (depPlugin) visit(depPlugin);
|
|
1069
|
+
}
|
|
1070
|
+
visiting.delete(plugin2.id);
|
|
1071
|
+
visited.add(plugin2.id);
|
|
1072
|
+
sorted.push(plugin2);
|
|
1073
|
+
}
|
|
1074
|
+
__name(visit, "visit");
|
|
1075
|
+
for (const plugin2 of plugins) visit(plugin2);
|
|
1076
|
+
return sorted;
|
|
1154
1077
|
}
|
|
1155
|
-
__name(
|
|
1156
|
-
function
|
|
1157
|
-
|
|
1078
|
+
__name(resolveDependencies, "resolveDependencies");
|
|
1079
|
+
async function cliCore(argv, entry, options, plugins) {
|
|
1080
|
+
const decorators = createDecorators();
|
|
1081
|
+
const pluginContext = createPluginContext(decorators, createInitialSubCommands(options, entry));
|
|
1082
|
+
const resolvedPlugins = await applyPlugins(pluginContext, [...plugins, ...options.plugins || []]);
|
|
1083
|
+
const cliOptions = normalizeCliOptions(options, decorators, pluginContext);
|
|
1084
|
+
const tokens = parseArgs(argv);
|
|
1085
|
+
const resolved = resolveCommandTree(tokens, entry, cliOptions);
|
|
1086
|
+
const { commandName: name, command, callMode, commandPath, depth, levelSubCommands } = resolved;
|
|
1087
|
+
if (!command) throw new Error(`Command not found: ${name || ""}`);
|
|
1088
|
+
if (levelSubCommands) cliOptions.subCommands = levelSubCommands;
|
|
1089
|
+
const resolvedCommand = isLazyCommand(command) ? await resolveLazyCommand(command, name, true) : command;
|
|
1090
|
+
const args = resolveArguments(pluginContext, getCommandArgs(resolvedCommand));
|
|
1091
|
+
const skipPositional = depth > 0 ? depth - 1 : -1;
|
|
1092
|
+
const { explicit, values, positionals, rest, error } = resolveArgs(args, tokens, {
|
|
1093
|
+
shortGrouping: true,
|
|
1094
|
+
toKebab: resolvedCommand.toKebab,
|
|
1095
|
+
skipPositional
|
|
1096
|
+
});
|
|
1097
|
+
const omitted = resolved.omitted;
|
|
1098
|
+
return await executeCommand(resolvedCommand, await createCommandContext({
|
|
1099
|
+
args,
|
|
1100
|
+
explicit,
|
|
1101
|
+
values,
|
|
1102
|
+
positionals,
|
|
1103
|
+
rest,
|
|
1104
|
+
argv,
|
|
1105
|
+
tokens,
|
|
1106
|
+
omitted,
|
|
1107
|
+
callMode,
|
|
1108
|
+
commandPath,
|
|
1109
|
+
command: resolvedCommand,
|
|
1110
|
+
extensions: getPluginExtensions(resolvedPlugins),
|
|
1111
|
+
validationError: error,
|
|
1112
|
+
cliOptions
|
|
1113
|
+
}), decorators.commandDecorators);
|
|
1158
1114
|
}
|
|
1159
|
-
__name(
|
|
1160
|
-
function
|
|
1161
|
-
|
|
1115
|
+
__name(cliCore, "cliCore");
|
|
1116
|
+
async function applyPlugins(pluginContext, plugins) {
|
|
1117
|
+
const sortedPlugins = resolveDependencies(plugins);
|
|
1118
|
+
try {
|
|
1119
|
+
for (const plugin2 of sortedPlugins)
|
|
1120
|
+
await plugin2(pluginContext);
|
|
1121
|
+
} catch (error) {
|
|
1122
|
+
console.error("Error loading plugin:", error.message);
|
|
1123
|
+
}
|
|
1124
|
+
return sortedPlugins;
|
|
1162
1125
|
}
|
|
1163
|
-
__name(
|
|
1164
|
-
|
|
1165
|
-
|
|
1126
|
+
__name(applyPlugins, "applyPlugins");
|
|
1127
|
+
function getCommandArgs(cmd) {
|
|
1128
|
+
if (isLazyCommand(cmd)) return cmd.args || create();
|
|
1129
|
+
else if (typeof cmd === "object") return cmd.args || create();
|
|
1130
|
+
else return create();
|
|
1166
1131
|
}
|
|
1167
|
-
__name(
|
|
1168
|
-
function
|
|
1169
|
-
return Object.
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1132
|
+
__name(getCommandArgs, "getCommandArgs");
|
|
1133
|
+
function resolveArguments(pluginContext, args) {
|
|
1134
|
+
return Object.assign(create(), Object.fromEntries(pluginContext.globalOptions), args);
|
|
1135
|
+
}
|
|
1136
|
+
__name(resolveArguments, "resolveArguments");
|
|
1137
|
+
var isObject = /* @__PURE__ */ __name((val) => val !== null && typeof val === "object", "isObject");
|
|
1138
|
+
function createInitialSubCommands(options, entryCmd) {
|
|
1139
|
+
const hasSubCommands = options.subCommands ? options.subCommands instanceof Map ? options.subCommands.size > 0 : isObject(options.subCommands) && Object.keys(options.subCommands).length > 0 : false;
|
|
1140
|
+
const subCommands = new Map(options.subCommands instanceof Map ? options.subCommands : []);
|
|
1141
|
+
if (!(options.subCommands instanceof Map) && isObject(options.subCommands)) for (const [name, cmd] of Object.entries(options.subCommands)) subCommands.set(name, cmd);
|
|
1142
|
+
if (hasSubCommands) {
|
|
1143
|
+
if (isLazyCommand(entryCmd)) {
|
|
1144
|
+
const entryCopy = Object.assign((...args) => entryCmd(...args), entryCmd, { entry: true });
|
|
1145
|
+
subCommands.set(resolveEntryName(entryCopy), entryCopy);
|
|
1146
|
+
} else if (typeof entryCmd === "object") {
|
|
1147
|
+
const entryCopy = Object.assign(create(), entryCmd, { entry: true });
|
|
1148
|
+
subCommands.set(resolveEntryName(entryCopy), entryCopy);
|
|
1149
|
+
} else if (typeof entryCmd === "function") {
|
|
1150
|
+
const name = entryCmd.name || "(anonymous)";
|
|
1151
|
+
subCommands.set(name, {
|
|
1152
|
+
run: entryCmd,
|
|
1153
|
+
name,
|
|
1154
|
+
entry: true
|
|
1155
|
+
});
|
|
1180
1156
|
}
|
|
1181
|
-
|
|
1182
|
-
|
|
1157
|
+
}
|
|
1158
|
+
return subCommands;
|
|
1183
1159
|
}
|
|
1184
|
-
__name(
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1160
|
+
__name(createInitialSubCommands, "createInitialSubCommands");
|
|
1161
|
+
function normalizeCliOptions(options, decorators, pluginContext) {
|
|
1162
|
+
const subCommands = new Map(pluginContext.subCommands);
|
|
1163
|
+
const resolvedOptions = Object.assign(create(), CLI_OPTIONS_DEFAULT, options, { subCommands });
|
|
1164
|
+
if (resolvedOptions.renderHeader === void 0) resolvedOptions.renderHeader = decorators.getHeaderRenderer();
|
|
1165
|
+
if (resolvedOptions.renderUsage === void 0) resolvedOptions.renderUsage = decorators.getUsageRenderer();
|
|
1166
|
+
if (resolvedOptions.renderValidationErrors === void 0) resolvedOptions.renderValidationErrors = decorators.getValidationErrorsRenderer();
|
|
1167
|
+
return resolvedOptions;
|
|
1188
1168
|
}
|
|
1189
|
-
__name(
|
|
1190
|
-
|
|
1191
|
-
return
|
|
1169
|
+
__name(normalizeCliOptions, "normalizeCliOptions");
|
|
1170
|
+
function getPositionalTokens(tokens) {
|
|
1171
|
+
return tokens.filter((t) => t.kind === "positional").map((t) => t.value).filter((v) => !!v);
|
|
1192
1172
|
}
|
|
1193
|
-
__name(
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1173
|
+
__name(getPositionalTokens, "getPositionalTokens");
|
|
1174
|
+
function resolveCommandTree(tokens, entry, options) {
|
|
1175
|
+
const positionals = getPositionalTokens(tokens);
|
|
1176
|
+
function resolveAsEntry() {
|
|
1177
|
+
if (typeof entry === "function") if ("commandName" in entry && entry.commandName) return {
|
|
1178
|
+
commandName: entry.commandName,
|
|
1179
|
+
command: entry,
|
|
1180
|
+
callMode: "entry",
|
|
1181
|
+
commandPath: [],
|
|
1182
|
+
depth: 0,
|
|
1183
|
+
omitted: options.subCommands.size > 0 && !positionals[0],
|
|
1184
|
+
levelSubCommands: options.subCommands.size > 0 ? options.subCommands : void 0
|
|
1185
|
+
};
|
|
1186
|
+
else return {
|
|
1187
|
+
command: {
|
|
1188
|
+
run: entry,
|
|
1189
|
+
entry: true
|
|
1190
|
+
},
|
|
1191
|
+
callMode: "entry",
|
|
1192
|
+
commandPath: [],
|
|
1193
|
+
depth: 0,
|
|
1194
|
+
omitted: options.subCommands.size > 0 && !positionals[0],
|
|
1195
|
+
levelSubCommands: options.subCommands.size > 0 ? options.subCommands : void 0
|
|
1196
|
+
};
|
|
1197
|
+
else if (typeof entry === "object") return {
|
|
1198
|
+
commandName: resolveEntryName(entry),
|
|
1199
|
+
command: entry,
|
|
1200
|
+
callMode: "entry",
|
|
1201
|
+
commandPath: [],
|
|
1202
|
+
depth: 0,
|
|
1203
|
+
omitted: options.subCommands.size > 0 && !positionals[0],
|
|
1204
|
+
levelSubCommands: options.subCommands.size > 0 ? options.subCommands : void 0
|
|
1205
|
+
};
|
|
1206
|
+
else return {
|
|
1207
|
+
callMode: "unexpected",
|
|
1208
|
+
commandPath: [],
|
|
1209
|
+
depth: 0,
|
|
1210
|
+
omitted: false,
|
|
1211
|
+
levelSubCommands: void 0
|
|
1212
|
+
};
|
|
1202
1213
|
}
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
const
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1214
|
+
__name(resolveAsEntry, "resolveAsEntry");
|
|
1215
|
+
if (positionals.length === 0 || options.subCommands.size === 0) return resolveAsEntry();
|
|
1216
|
+
let currentSubCommands = options.subCommands;
|
|
1217
|
+
let resolvedCommand;
|
|
1218
|
+
let resolvedName;
|
|
1219
|
+
const commandPath = [];
|
|
1220
|
+
let depth = 0;
|
|
1221
|
+
for (let i = 0; i < positionals.length; i++) {
|
|
1222
|
+
const token = positionals[i];
|
|
1223
|
+
const cmd = currentSubCommands.get(token);
|
|
1224
|
+
if (cmd == null) {
|
|
1225
|
+
if (depth === 0) {
|
|
1226
|
+
if (options.fallbackToEntry) return resolveAsEntry();
|
|
1227
|
+
return {
|
|
1228
|
+
commandName: token,
|
|
1229
|
+
callMode: "unexpected",
|
|
1230
|
+
commandPath: [],
|
|
1231
|
+
depth: 0,
|
|
1232
|
+
omitted: false,
|
|
1233
|
+
levelSubCommands: void 0
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
break;
|
|
1216
1237
|
}
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
+
let resolved = cmd;
|
|
1239
|
+
if (typeof cmd === "function" && cmd.commandName == null) resolved = Object.assign((...args) => cmd(...args), cmd, { commandName: token });
|
|
1240
|
+
else if (typeof cmd === "object" && cmd.name == null) resolved = Object.assign(create(), cmd, { name: token });
|
|
1241
|
+
resolvedCommand = resolved;
|
|
1242
|
+
resolvedName = token;
|
|
1243
|
+
commandPath.push(token);
|
|
1244
|
+
depth++;
|
|
1245
|
+
const nestedSubCommands = getCommandSubCommands(cmd);
|
|
1246
|
+
if (nestedSubCommands && nestedSubCommands.size > 0) currentSubCommands = nestedSubCommands;
|
|
1247
|
+
else break;
|
|
1248
|
+
}
|
|
1249
|
+
if (!resolvedCommand) return resolveAsEntry();
|
|
1250
|
+
const resolvedSubCommands = getCommandSubCommands(resolvedCommand);
|
|
1251
|
+
const omitted = resolvedSubCommands != null && resolvedSubCommands.size > 0;
|
|
1252
|
+
let levelSubCommands;
|
|
1253
|
+
if (omitted && resolvedSubCommands) {
|
|
1254
|
+
levelSubCommands = new Map(resolvedSubCommands);
|
|
1255
|
+
let entryCopy;
|
|
1256
|
+
if (typeof resolvedCommand === "function") entryCopy = Object.assign((...args) => resolvedCommand(...args), resolvedCommand, { entry: true });
|
|
1257
|
+
else entryCopy = Object.assign(create(), resolvedCommand, { entry: true });
|
|
1258
|
+
levelSubCommands.set(resolvedName || resolveEntryName(entryCopy), entryCopy);
|
|
1259
|
+
}
|
|
1260
|
+
return {
|
|
1261
|
+
commandName: resolvedName,
|
|
1262
|
+
command: resolvedCommand,
|
|
1263
|
+
callMode: depth > 0 ? "subCommand" : "entry",
|
|
1264
|
+
commandPath,
|
|
1265
|
+
depth,
|
|
1266
|
+
omitted,
|
|
1267
|
+
levelSubCommands
|
|
1268
|
+
};
|
|
1238
1269
|
}
|
|
1239
|
-
__name(
|
|
1240
|
-
function
|
|
1241
|
-
return
|
|
1242
|
-
const elements = [];
|
|
1243
|
-
if (!arg.multiple || arg.required) elements.push(`<${name}>`);
|
|
1244
|
-
if (arg.multiple) elements.push(`[<${name}> ...]`);
|
|
1245
|
-
return elements.join(" ");
|
|
1246
|
-
}).join(" ") : "";
|
|
1270
|
+
__name(resolveCommandTree, "resolveCommandTree");
|
|
1271
|
+
function resolveEntryName(entry) {
|
|
1272
|
+
return isLazyCommand(entry) ? entry.commandName || "(anonymous)" : entry.name || "(anonymous)";
|
|
1247
1273
|
}
|
|
1248
|
-
__name(
|
|
1249
|
-
function
|
|
1250
|
-
const
|
|
1251
|
-
for (const
|
|
1252
|
-
|
|
1274
|
+
__name(resolveEntryName, "resolveEntryName");
|
|
1275
|
+
function getPluginExtensions(plugins) {
|
|
1276
|
+
const extensions = create();
|
|
1277
|
+
for (const plugin2 of plugins) if (plugin2.extension) {
|
|
1278
|
+
const key = plugin2.id;
|
|
1279
|
+
if (extensions[key]) console.warn(`Plugin "${key}" is already installed. Ignore it for command context extending.`);
|
|
1280
|
+
else extensions[key] = plugin2.extension;
|
|
1281
|
+
}
|
|
1282
|
+
return extensions;
|
|
1253
1283
|
}
|
|
1254
|
-
__name(
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
cachedCommands = (await Promise.all(subCommands.map(async ([name, cmd2]) => await resolveLazyCommand(cmd2, name)))).filter((cmd2) => !cmd2.internal).filter(Boolean);
|
|
1272
|
-
cachedCommands.sort((a, b) => {
|
|
1273
|
-
if (a.entry && !b.entry) return -1;
|
|
1274
|
-
if (!a.entry && b.entry) return 1;
|
|
1275
|
-
if (a.name && b.name) return a.name.localeCompare(b.name);
|
|
1276
|
-
if (a.name && !b.name) return -1;
|
|
1277
|
-
if (!a.name && b.name) return 1;
|
|
1278
|
-
return 0;
|
|
1279
|
-
});
|
|
1280
|
-
return cachedCommands;
|
|
1281
|
-
}
|
|
1282
|
-
__name(loadCommands, "loadCommands");
|
|
1283
|
-
return {
|
|
1284
|
-
text: localizable(ctx, cmd, i18n?.translate),
|
|
1285
|
-
loadCommands
|
|
1286
|
-
};
|
|
1287
|
-
}, "extension"),
|
|
1288
|
-
setup: /* @__PURE__ */ __name((ctx) => {
|
|
1289
|
-
ctx.decorateHeaderRenderer(async (_baseRenderer, cmdCtx) => await renderHeader(cmdCtx));
|
|
1290
|
-
ctx.decorateUsageRenderer(async (_baseRenderer, cmdCtx) => await renderUsage(cmdCtx));
|
|
1291
|
-
ctx.decorateValidationErrorsRenderer(async (_baseRenderer, cmdCtx, error) => await renderValidationErrors(cmdCtx, error));
|
|
1292
|
-
}, "setup")
|
|
1293
|
-
});
|
|
1284
|
+
__name(getPluginExtensions, "getPluginExtensions");
|
|
1285
|
+
async function executeCommand(cmd, ctx, decorators) {
|
|
1286
|
+
const baseRunner = cmd.run || NOOP;
|
|
1287
|
+
const decoratedRunner = decorators.reduceRight((runner, decorator2) => decorator2(runner), baseRunner);
|
|
1288
|
+
try {
|
|
1289
|
+
if (ctx.env.onBeforeCommand) await ctx.env.onBeforeCommand(ctx);
|
|
1290
|
+
const result = await decoratedRunner(ctx);
|
|
1291
|
+
if (ctx.env.onAfterCommand) await ctx.env.onAfterCommand(ctx, result);
|
|
1292
|
+
return typeof result === "string" ? result : void 0;
|
|
1293
|
+
} catch (error) {
|
|
1294
|
+
if (ctx.env.onErrorCommand) try {
|
|
1295
|
+
await ctx.env.onErrorCommand(ctx, error);
|
|
1296
|
+
} catch (hookError) {
|
|
1297
|
+
console.error("Error in onErrorCommand hook:", hookError);
|
|
1298
|
+
}
|
|
1299
|
+
throw error;
|
|
1300
|
+
}
|
|
1294
1301
|
}
|
|
1295
|
-
__name(
|
|
1302
|
+
__name(executeCommand, "executeCommand");
|
|
1296
1303
|
|
|
1297
|
-
// ../../node_modules/.bun/gunshi@0.
|
|
1304
|
+
// ../../node_modules/.bun/gunshi@0.32.0/node_modules/gunshi/lib/cli-DfaFk6tk.js
|
|
1298
1305
|
var pluginId2 = namespacedId("global");
|
|
1299
1306
|
var decorator = /* @__PURE__ */ __name((baseRunner) => async (ctx) => {
|
|
1300
1307
|
const { values, validationError, extensions: { [pluginId2]: { showVersion, showHeader, showUsage, showValidationErrors } } } = ctx;
|
|
@@ -1310,10 +1317,12 @@ var decorator = /* @__PURE__ */ __name((baseRunner) => async (ctx) => {
|
|
|
1310
1317
|
}
|
|
1311
1318
|
return;
|
|
1312
1319
|
}
|
|
1313
|
-
if (validationError)
|
|
1320
|
+
if (validationError) {
|
|
1321
|
+
await showValidationErrors(validationError);
|
|
1322
|
+
throw validationError;
|
|
1323
|
+
}
|
|
1314
1324
|
return baseRunner(ctx);
|
|
1315
1325
|
}, "decorator");
|
|
1316
|
-
var decorator_default = decorator;
|
|
1317
1326
|
function extension(ctx) {
|
|
1318
1327
|
return {
|
|
1319
1328
|
showVersion: /* @__PURE__ */ __name(() => {
|
|
@@ -1359,7 +1368,7 @@ function global() {
|
|
|
1359
1368
|
extension,
|
|
1360
1369
|
setup(ctx) {
|
|
1361
1370
|
for (const [name, schema] of Object.entries(COMMON_ARGS)) ctx.addGlobalOption(name, schema);
|
|
1362
|
-
ctx.decorateCommand(
|
|
1371
|
+
ctx.decorateCommand(decorator);
|
|
1363
1372
|
}
|
|
1364
1373
|
});
|
|
1365
1374
|
}
|
|
@@ -1368,13 +1377,37 @@ async function cli(args, entry, options = {}) {
|
|
|
1368
1377
|
return cliCore(args, entry, options, [global(), renderer()]);
|
|
1369
1378
|
}
|
|
1370
1379
|
__name(cli, "cli");
|
|
1380
|
+
|
|
1381
|
+
// ../../node_modules/.bun/gunshi@0.32.0/node_modules/gunshi/lib/definition.js
|
|
1382
|
+
function define(definition) {
|
|
1383
|
+
return definition;
|
|
1384
|
+
}
|
|
1385
|
+
__name(define, "define");
|
|
1371
1386
|
/*! Bundled license information:
|
|
1372
1387
|
|
|
1373
|
-
gunshi/lib/
|
|
1374
|
-
gunshi/lib/
|
|
1375
|
-
gunshi/lib/
|
|
1376
|
-
gunshi/lib/src-
|
|
1377
|
-
gunshi/lib/
|
|
1388
|
+
gunshi/lib/core-D1daCTTE.js:
|
|
1389
|
+
gunshi/lib/constants-D_ixLD32.js:
|
|
1390
|
+
gunshi/lib/utils-jNy8sqR5.js:
|
|
1391
|
+
gunshi/lib/src-dTYUlEw_.js:
|
|
1392
|
+
gunshi/lib/context.js:
|
|
1393
|
+
gunshi/lib/cli-DfaFk6tk.js:
|
|
1394
|
+
gunshi/lib/definition.js:
|
|
1395
|
+
gunshi/lib/index.js:
|
|
1396
|
+
gunshi/lib/index.js:
|
|
1397
|
+
(**
|
|
1398
|
+
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
1399
|
+
* @license MIT
|
|
1400
|
+
*)
|
|
1401
|
+
|
|
1402
|
+
gunshi/lib/core-BKtZQ6dG.js:
|
|
1403
|
+
(**
|
|
1404
|
+
* forked from `nodejs/node` (`pkgjs/parseargs`)
|
|
1405
|
+
* repository url: https://github.com/nodejs/node (https://github.com/pkgjs/parseargs)
|
|
1406
|
+
* code url: https://github.com/nodejs/node/blob/main/lib/internal/util/parse_args/parse_args.js
|
|
1407
|
+
*
|
|
1408
|
+
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
1409
|
+
* @license MIT
|
|
1410
|
+
*)
|
|
1378
1411
|
(**
|
|
1379
1412
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
1380
1413
|
* @license MIT
|
|
@@ -1382,5 +1415,5 @@ gunshi/lib/cli-l4AYjN-O.js:
|
|
|
1382
1415
|
*/
|
|
1383
1416
|
|
|
1384
1417
|
export { cli, define };
|
|
1385
|
-
//# sourceMappingURL=chunk-
|
|
1386
|
-
//# sourceMappingURL=chunk-
|
|
1418
|
+
//# sourceMappingURL=chunk-MGUGRIW2.js.map
|
|
1419
|
+
//# sourceMappingURL=chunk-MGUGRIW2.js.map
|