gunshi 0.35.1 → 0.35.2
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/lib/bone.d.ts +2 -2
- package/lib/bone.js +1 -1
- package/lib/{cli-DoX4INTi.js → cli-DnXk5aCq.js} +8 -3
- package/lib/combinators.d.ts +2 -10
- package/lib/combinators.js +80 -7
- package/lib/context-CAPhwgJJ.js +119 -0
- package/lib/context.d.ts +2 -2
- package/lib/context.js +1 -90
- package/lib/core-CbE1I4Jl.js +518 -0
- package/lib/definition.d.ts +2 -2
- package/lib/definition.js +1 -1
- package/lib/error-6srXBX7u.d.ts +87 -0
- package/lib/error-xSnOOdnr.js +65 -0
- package/lib/generator.d.ts +1 -1
- package/lib/generator.js +2 -2
- package/lib/index.d.ts +4 -4
- package/lib/index.js +7 -7
- package/lib/{core-CFEvRYOJ.js → plugin-DhJZVIbl.js} +7 -0
- package/lib/plugin.d.ts +4 -4
- package/lib/plugin.js +5 -10
- package/lib/renderer.d.ts +3 -3
- package/lib/renderer.js +1 -1
- package/lib/{resolver-mxPNDBm_.d.ts → resolver-CgkhQ6Tt.d.ts} +62 -4
- package/lib/{core-xgWIcbHL.js → resolver-UFOtObbe.js} +158 -456
- package/lib/{src-B4uHG_qb.js → src-DbfZvEe0.js} +74 -9
- package/lib/{types-DZ0S_FSe.d.ts → types-CD5eRJFK.d.ts} +18 -1
- package/lib/utils-BKhsrjPW.js +32 -0
- package/lib/utils.d.ts +8 -3
- package/lib/utils.js +109 -1
- package/package.json +7 -7
- package/lib/constants-BkgP86Yw.d.ts +0 -11
- package/lib/constants-CQq1R_68.js +0 -29
- package/lib/utils-DNVHO9MQ.js +0 -131
package/lib/bone.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema,
|
|
2
|
-
import { C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, O as ValidationErrorsDecorator, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { i as Args, n as ArgSchema, r as ArgValues, u as ArgToken } from "./resolver-CgkhQ6Tt.js";
|
|
2
|
+
import { C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, O as ValidationErrorsDecorator, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-CD5eRJFK.js";
|
|
3
3
|
|
|
4
4
|
//#region src/cli/bone.d.ts
|
|
5
5
|
/**
|
package/lib/bone.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
1
|
+
import { r as hasPriorityValidationError } from "./error-xSnOOdnr.js";
|
|
2
|
+
import { t as plugin } from "./plugin-DhJZVIbl.js";
|
|
3
|
+
import { a as namespacedId, o as COMMON_ARGS, t as renderer } from "./src-DbfZvEe0.js";
|
|
4
|
+
import { t as cliCore } from "./core-CbE1I4Jl.js";
|
|
4
5
|
//#region ../plugin-global/src/types.ts
|
|
5
6
|
/**
|
|
6
7
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
@@ -24,6 +25,10 @@ const pluginId = namespacedId("global");
|
|
|
24
25
|
*/
|
|
25
26
|
const decorator = (baseRunner) => async (ctx) => {
|
|
26
27
|
const { values, validationError, extensions: { [pluginId]: { showVersion, showHeader, showUsage, showValidationErrors } } } = ctx;
|
|
28
|
+
if (hasPriorityValidationError(validationError)) {
|
|
29
|
+
await showValidationErrors(validationError);
|
|
30
|
+
throw validationError;
|
|
31
|
+
}
|
|
27
32
|
if (values.version) return showVersion();
|
|
28
33
|
const buf = [];
|
|
29
34
|
const header = await showHeader();
|
package/lib/combinators.d.ts
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema } from "./resolver-
|
|
1
|
+
import { i as Args, n as ArgSchema } from "./resolver-CgkhQ6Tt.js";
|
|
2
2
|
|
|
3
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
4
|
-
/**
|
|
5
|
-
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
6
|
-
* @license MIT
|
|
7
|
-
*/
|
|
3
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.28.0/node_modules/args-tokens/lib/combinators.d.ts
|
|
8
4
|
|
|
9
5
|
//#region src/combinators.d.ts
|
|
10
|
-
/**
|
|
11
|
-
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
12
|
-
* @license MIT
|
|
13
|
-
*/
|
|
14
6
|
/**
|
|
15
7
|
* A combinator produced by combinator factory functions.
|
|
16
8
|
*
|
package/lib/combinators.js
CHANGED
|
@@ -1,8 +1,81 @@
|
|
|
1
|
-
|
|
1
|
+
import { t as formatChoices } from "./utils-BKhsrjPW.js";
|
|
2
|
+
import { n as ArgsValidationErrorKeys, t as ArgsValidationError } from "./resolver-UFOtObbe.js";
|
|
3
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.28.0/node_modules/args-tokens/lib/combinators.js
|
|
4
|
+
/**
|
|
5
|
+
* Parser combinator factory functions for composable argument schema construction.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { parseArgs, resolveArgs } from 'args-tokens'
|
|
10
|
+
* import {
|
|
11
|
+
* args,
|
|
12
|
+
* string,
|
|
13
|
+
* integer,
|
|
14
|
+
* boolean,
|
|
15
|
+
* positional,
|
|
16
|
+
* choice,
|
|
17
|
+
* withDefault,
|
|
18
|
+
* multiple,
|
|
19
|
+
* required,
|
|
20
|
+
* short,
|
|
21
|
+
* map,
|
|
22
|
+
* merge,
|
|
23
|
+
* extend
|
|
24
|
+
* } from 'args-tokens/combinators'
|
|
25
|
+
*
|
|
26
|
+
* // Define reusable schema groups with args()
|
|
27
|
+
* const common = args({
|
|
28
|
+
* help: short(boolean(), 'h'),
|
|
29
|
+
* verbose: boolean()
|
|
30
|
+
* })
|
|
31
|
+
*
|
|
32
|
+
* const network = args({
|
|
33
|
+
* port: short(withDefault(integer({ min: 1, max: 65535 }), 8080), 'p'),
|
|
34
|
+
* host: required(short(string({ minLength: 1 }), 'o'))
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* // Compose schemas with merge()
|
|
38
|
+
* const schema = merge(
|
|
39
|
+
* common,
|
|
40
|
+
* network,
|
|
41
|
+
* args({
|
|
42
|
+
* command: positional()
|
|
43
|
+
* })
|
|
44
|
+
* )
|
|
45
|
+
*
|
|
46
|
+
* const argv = ['dev', '--port', '9131', '--host', 'example.com', '--verbose']
|
|
47
|
+
* const tokens = parseArgs(argv)
|
|
48
|
+
* const { values } = resolveArgs(schema, tokens)
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @experimental This module is experimental and may change in future versions.
|
|
52
|
+
*
|
|
53
|
+
* @module
|
|
54
|
+
*/
|
|
2
55
|
/**
|
|
3
56
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
4
57
|
* @license MIT
|
|
5
58
|
*/
|
|
59
|
+
function createInvalidTypeError(message, expected, actual) {
|
|
60
|
+
return new ArgsValidationError(message, {
|
|
61
|
+
code: ArgsValidationErrorKeys.invalidType,
|
|
62
|
+
values: {
|
|
63
|
+
expected,
|
|
64
|
+
actual
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function createInvalidChoiceError(message, choices, actual) {
|
|
69
|
+
return new ArgsValidationError(message, {
|
|
70
|
+
code: ArgsValidationErrorKeys.invalidChoice,
|
|
71
|
+
values: {
|
|
72
|
+
expected: "enum",
|
|
73
|
+
choices: formatChoices(choices),
|
|
74
|
+
choiceValues: [...choices],
|
|
75
|
+
actual
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
6
79
|
/**
|
|
7
80
|
* Create a string argument schema with optional validation.
|
|
8
81
|
*
|
|
@@ -63,7 +136,7 @@ function number(opts) {
|
|
|
63
136
|
...opts?.required != null ? { required: opts.required } : {},
|
|
64
137
|
parse(value) {
|
|
65
138
|
const n = Number(value);
|
|
66
|
-
if (value.trim() === "" || isNaN(n)) throw
|
|
139
|
+
if (value.trim() === "" || isNaN(n)) throw createInvalidTypeError(`Expected a number, got '${value}'`, "number", value);
|
|
67
140
|
if (opts?.min != null && n < opts.min) throw new RangeError(`Number must be >= ${opts.min}, got ${n}`);
|
|
68
141
|
if (opts?.max != null && n > opts.max) throw new RangeError(`Number must be <= ${opts.max}, got ${n}`);
|
|
69
142
|
return n;
|
|
@@ -97,9 +170,9 @@ function integer(opts) {
|
|
|
97
170
|
...opts?.short != null ? { short: opts.short } : {},
|
|
98
171
|
...opts?.required != null ? { required: opts.required } : {},
|
|
99
172
|
parse(value) {
|
|
100
|
-
if (!/^-?\d+$/.test(value)) throw
|
|
173
|
+
if (!/^-?\d+$/.test(value)) throw createInvalidTypeError(`Expected an integer, got '${value}'`, "integer", value);
|
|
101
174
|
const n = Number.parseInt(value, 10);
|
|
102
|
-
if (isNaN(n)) throw
|
|
175
|
+
if (isNaN(n)) throw createInvalidTypeError(`Expected an integer, got '${value}'`, "integer", value);
|
|
103
176
|
if (opts?.min != null && n < opts.min) throw new RangeError(`Integer must be >= ${opts.min}, got ${n}`);
|
|
104
177
|
if (opts?.max != null && n > opts.max) throw new RangeError(`Integer must be <= ${opts.max}, got ${n}`);
|
|
105
178
|
return n;
|
|
@@ -134,9 +207,9 @@ function float(opts) {
|
|
|
134
207
|
...opts?.required != null ? { required: opts.required } : {},
|
|
135
208
|
parse(value) {
|
|
136
209
|
const trimmed = value.trim();
|
|
137
|
-
if (!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(trimmed)) throw
|
|
210
|
+
if (!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(trimmed)) throw createInvalidTypeError(`Expected a finite float, got '${value}'`, "float", value);
|
|
138
211
|
const n = Number.parseFloat(trimmed);
|
|
139
|
-
if (isNaN(n) || !isFinite(n)) throw
|
|
212
|
+
if (isNaN(n) || !isFinite(n)) throw createInvalidTypeError(`Expected a finite float, got '${value}'`, "float", value);
|
|
140
213
|
if (opts?.min != null && n < opts.min) throw new RangeError(`Float must be >= ${opts.min}, got ${n}`);
|
|
141
214
|
if (opts?.max != null && n > opts.max) throw new RangeError(`Float must be <= ${opts.max}, got ${n}`);
|
|
142
215
|
return n;
|
|
@@ -229,7 +302,7 @@ function choice(values, opts) {
|
|
|
229
302
|
...opts?.short != null ? { short: opts.short } : {},
|
|
230
303
|
...opts?.required != null ? { required: opts.required } : {},
|
|
231
304
|
parse(value) {
|
|
232
|
-
if (!values.includes(value)) throw
|
|
305
|
+
if (!values.includes(value)) throw createInvalidChoiceError(`Value must be one of: ${values.join(", ")}`, values, value);
|
|
233
306
|
return value;
|
|
234
307
|
}
|
|
235
308
|
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { create, deepFreeze, isLazyCommand, log } from "./utils.js";
|
|
2
|
+
//#region src/constants.ts
|
|
3
|
+
/**
|
|
4
|
+
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/
|
|
7
|
+
const ANONYMOUS_COMMAND_NAME = "(anonymous)";
|
|
8
|
+
/**
|
|
9
|
+
* A no-operation function.
|
|
10
|
+
*/
|
|
11
|
+
const NOOP = () => {};
|
|
12
|
+
const CLI_OPTIONS_DEFAULT = {
|
|
13
|
+
name: void 0,
|
|
14
|
+
description: void 0,
|
|
15
|
+
version: void 0,
|
|
16
|
+
cwd: void 0,
|
|
17
|
+
usageSilent: false,
|
|
18
|
+
subCommands: void 0,
|
|
19
|
+
leftMargin: 2,
|
|
20
|
+
middleMargin: 10,
|
|
21
|
+
usageOptionType: false,
|
|
22
|
+
usageOptionValue: true,
|
|
23
|
+
strict: false,
|
|
24
|
+
renderHeader: void 0,
|
|
25
|
+
renderUsage: void 0,
|
|
26
|
+
renderValidationErrors: void 0,
|
|
27
|
+
plugins: void 0,
|
|
28
|
+
fallbackToEntry: false
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/context.ts
|
|
32
|
+
/**
|
|
33
|
+
* The entry for gunshi context.
|
|
34
|
+
* This module is exported for the purpose of testing the command.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```js
|
|
38
|
+
* import { createCommandContext } from 'gunshi/context'
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @module
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
45
|
+
* @license MIT
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* Create a command context.
|
|
49
|
+
*
|
|
50
|
+
* @param param - A {@link CommandContextParams | parameters} to create a command context.
|
|
51
|
+
* @returns A {@link CommandContext | command context}, which is readonly.
|
|
52
|
+
*/
|
|
53
|
+
async function createCommandContext({ args = {}, explicit = {}, values = {}, positionals = [], rest = [], argv = [], tokens = [], command = {}, extensions = {}, cliOptions = {}, callMode = "entry", commandPath = [], omitted = false, validationError }) {
|
|
54
|
+
/**
|
|
55
|
+
* normailize the options schema and values, to avoid prototype pollution
|
|
56
|
+
*/
|
|
57
|
+
const _args = Object.entries(args).reduce((acc, [key, value]) => {
|
|
58
|
+
acc[key] = Object.assign(create(), value);
|
|
59
|
+
return acc;
|
|
60
|
+
}, create());
|
|
61
|
+
/**
|
|
62
|
+
* setup the environment
|
|
63
|
+
*/
|
|
64
|
+
const env = Object.assign(create(), CLI_OPTIONS_DEFAULT, cliOptions);
|
|
65
|
+
/**
|
|
66
|
+
* apply Command definition's rendering option with highest priority
|
|
67
|
+
*/
|
|
68
|
+
if (command.rendering) {
|
|
69
|
+
const { header, usage, validationErrors } = command.rendering;
|
|
70
|
+
if (header !== void 0) env.renderHeader = header;
|
|
71
|
+
if (usage !== void 0) env.renderUsage = usage;
|
|
72
|
+
if (validationErrors !== void 0) env.renderValidationErrors = validationErrors;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* create the command context
|
|
76
|
+
*/
|
|
77
|
+
const core = Object.assign(create(), {
|
|
78
|
+
name: getCommandName(command),
|
|
79
|
+
description: command.description,
|
|
80
|
+
omitted,
|
|
81
|
+
callMode,
|
|
82
|
+
commandPath,
|
|
83
|
+
env,
|
|
84
|
+
args: _args,
|
|
85
|
+
explicit,
|
|
86
|
+
values,
|
|
87
|
+
positionals,
|
|
88
|
+
rest,
|
|
89
|
+
_: argv,
|
|
90
|
+
tokens,
|
|
91
|
+
toKebab: command.toKebab,
|
|
92
|
+
log: cliOptions.usageSilent ? NOOP : log,
|
|
93
|
+
validationError
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* extend the command context with extensions
|
|
97
|
+
*/
|
|
98
|
+
if (Object.keys(extensions).length > 0) {
|
|
99
|
+
const ext = create(null);
|
|
100
|
+
Object.defineProperty(core, "extensions", {
|
|
101
|
+
value: ext,
|
|
102
|
+
writable: false,
|
|
103
|
+
enumerable: true,
|
|
104
|
+
configurable: true
|
|
105
|
+
});
|
|
106
|
+
for (const [key, extension] of Object.entries(extensions)) {
|
|
107
|
+
ext[key] = await extension.factory(core, command);
|
|
108
|
+
if (extension.onFactory) await extension.onFactory(core, command);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return deepFreeze(core, ["extensions"]);
|
|
112
|
+
}
|
|
113
|
+
function getCommandName(cmd) {
|
|
114
|
+
if (isLazyCommand(cmd)) return cmd.commandName || cmd.name || "(anonymous)";
|
|
115
|
+
else if (typeof cmd === "object") return cmd.name || "(anonymous)";
|
|
116
|
+
else return ANONYMOUS_COMMAND_NAME;
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
export { NOOP as i, ANONYMOUS_COMMAND_NAME as n, CLI_OPTIONS_DEFAULT as r, createCommandContext as t };
|
package/lib/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as Args,
|
|
2
|
-
import { _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, m as DefaultGunshiParams, n as CliOptions, r as Command, s as CommandContextExtension, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { i as Args, r as ArgValues, u as ArgToken } from "./resolver-CgkhQ6Tt.js";
|
|
2
|
+
import { _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, m as DefaultGunshiParams, n as CliOptions, r as Command, s as CommandContextExtension, x as LazyCommand, y as GunshiParams } from "./types-CD5eRJFK.js";
|
|
3
3
|
|
|
4
4
|
//#region src/context.d.ts
|
|
5
5
|
|
package/lib/context.js
CHANGED
|
@@ -1,91 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as log, i as isLazyCommand, n as deepFreeze, t as create } from "./utils-DNVHO9MQ.js";
|
|
3
|
-
//#region src/context.ts
|
|
4
|
-
/**
|
|
5
|
-
* The entry for gunshi context.
|
|
6
|
-
* This module is exported for the purpose of testing the command.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```js
|
|
10
|
-
* import { createCommandContext } from 'gunshi/context'
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @module
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
17
|
-
* @license MIT
|
|
18
|
-
*/
|
|
19
|
-
/**
|
|
20
|
-
* Create a command context.
|
|
21
|
-
*
|
|
22
|
-
* @param param - A {@link CommandContextParams | parameters} to create a command context.
|
|
23
|
-
* @returns A {@link CommandContext | command context}, which is readonly.
|
|
24
|
-
*/
|
|
25
|
-
async function createCommandContext({ args = {}, explicit = {}, values = {}, positionals = [], rest = [], argv = [], tokens = [], command = {}, extensions = {}, cliOptions = {}, callMode = "entry", commandPath = [], omitted = false, validationError }) {
|
|
26
|
-
/**
|
|
27
|
-
* normailize the options schema and values, to avoid prototype pollution
|
|
28
|
-
*/
|
|
29
|
-
const _args = Object.entries(args).reduce((acc, [key, value]) => {
|
|
30
|
-
acc[key] = Object.assign(create(), value);
|
|
31
|
-
return acc;
|
|
32
|
-
}, create());
|
|
33
|
-
/**
|
|
34
|
-
* setup the environment
|
|
35
|
-
*/
|
|
36
|
-
const env = Object.assign(create(), CLI_OPTIONS_DEFAULT, cliOptions);
|
|
37
|
-
/**
|
|
38
|
-
* apply Command definition's rendering option with highest priority
|
|
39
|
-
*/
|
|
40
|
-
if (command.rendering) {
|
|
41
|
-
const { header, usage, validationErrors } = command.rendering;
|
|
42
|
-
if (header !== void 0) env.renderHeader = header;
|
|
43
|
-
if (usage !== void 0) env.renderUsage = usage;
|
|
44
|
-
if (validationErrors !== void 0) env.renderValidationErrors = validationErrors;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* create the command context
|
|
48
|
-
*/
|
|
49
|
-
const core = Object.assign(create(), {
|
|
50
|
-
name: getCommandName(command),
|
|
51
|
-
description: command.description,
|
|
52
|
-
omitted,
|
|
53
|
-
callMode,
|
|
54
|
-
commandPath,
|
|
55
|
-
env,
|
|
56
|
-
args: _args,
|
|
57
|
-
explicit,
|
|
58
|
-
values,
|
|
59
|
-
positionals,
|
|
60
|
-
rest,
|
|
61
|
-
_: argv,
|
|
62
|
-
tokens,
|
|
63
|
-
toKebab: command.toKebab,
|
|
64
|
-
log: cliOptions.usageSilent ? NOOP : log,
|
|
65
|
-
validationError
|
|
66
|
-
});
|
|
67
|
-
/**
|
|
68
|
-
* extend the command context with extensions
|
|
69
|
-
*/
|
|
70
|
-
if (Object.keys(extensions).length > 0) {
|
|
71
|
-
const ext = create(null);
|
|
72
|
-
Object.defineProperty(core, "extensions", {
|
|
73
|
-
value: ext,
|
|
74
|
-
writable: false,
|
|
75
|
-
enumerable: true,
|
|
76
|
-
configurable: true
|
|
77
|
-
});
|
|
78
|
-
for (const [key, extension] of Object.entries(extensions)) {
|
|
79
|
-
ext[key] = await extension.factory(core, command);
|
|
80
|
-
if (extension.onFactory) await extension.onFactory(core, command);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return deepFreeze(core, ["extensions"]);
|
|
84
|
-
}
|
|
85
|
-
function getCommandName(cmd) {
|
|
86
|
-
if (isLazyCommand(cmd)) return cmd.commandName || cmd.name || "(anonymous)";
|
|
87
|
-
else if (typeof cmd === "object") return cmd.name || "(anonymous)";
|
|
88
|
-
else return ANONYMOUS_COMMAND_NAME;
|
|
89
|
-
}
|
|
90
|
-
//#endregion
|
|
1
|
+
import { t as createCommandContext } from "./context-CAPhwgJJ.js";
|
|
91
2
|
export { createCommandContext };
|