gunshi 0.27.5 → 0.28.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/lib/bone.d.ts +1 -1
- package/lib/bone.js +1 -3
- package/lib/{cli-BtnhCdFu.js → cli-l4AYjN-O.js} +3 -3
- package/lib/{plugin-DvvZ2zsE.d.ts → constants-Cqazor4w.d.ts} +1 -1
- package/lib/constants-WviiKqbt.js +26 -0
- package/lib/{context-DRQZ3doU.js → context-CHDIbgwd.js} +5 -28
- package/lib/context.d.ts +101 -2
- package/lib/context.js +1 -2
- package/lib/core-C9P_Gd_f.js +881 -0
- package/lib/definition.d.ts +240 -4
- package/lib/definition.js +2 -2
- package/lib/generator.d.ts +2 -2
- package/lib/generator.js +8 -7
- package/lib/index.d.ts +178 -7
- package/lib/index.js +6 -7
- package/lib/plugin.d.ts +4 -4
- package/lib/plugin.js +3 -3
- package/lib/renderer.d.ts +2 -6
- package/lib/renderer.js +1 -4
- package/lib/{src-BXKp6yTi.js → src-CfO5ab2f.js} +13 -11
- package/lib/{types-Bh6G4DvQ.d.ts → types-DSyU38G8.d.ts} +25 -0
- package/lib/{utils-DA31tfdY.js → utils-DNS9AIR_.js} +44 -3
- package/lib/utils.d.ts +55 -3
- package/lib/utils.js +2 -2
- package/package.json +7 -9
- package/lib/context-DZzjf_Et.d.ts +0 -97
- package/lib/core-D15eimMG.js +0 -339
- package/lib/definition-DhDR8aNJ.d.ts +0 -239
- package/lib/index-DuyhzAeh.d.ts +0 -175
- package/lib/utils-DPF_9WLN.d.ts +0 -48
- /package/lib/{plugin-vBhmK2n3.js → core-eN5xmB3s.js} +0 -0
package/lib/bone.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as SubCommandable, C as GunshiParams, D as Prettify, E as NormalizeToGunshiParams, O as RendererDecorator, S as ExtractExtensions, T as LazyCommand, _ as Commandable, a as Awaitable, b as ExtractArgExplicitlyProvided, c as CommandCallMode, d as CommandContextExtension, f as CommandDecorator, g as CommandRunner, h as CommandLoader, i as Args, j as ValidationErrorsDecorator, k as RenderingOptions, l as CommandContext, m as CommandExamplesFetcher, n as ArgToken, o as CliOptions, p as CommandEnvironment, r as ArgValues, s as Command, t as ArgSchema, u as CommandContextCore, v as DefaultGunshiParams, w as GunshiParamsConstraint, x as ExtractArgs, y as ExtendContext } from "./types-
|
|
1
|
+
import { A as SubCommandable, C as GunshiParams, D as Prettify, E as NormalizeToGunshiParams, O as RendererDecorator, S as ExtractExtensions, T as LazyCommand, _ as Commandable, a as Awaitable, b as ExtractArgExplicitlyProvided, c as CommandCallMode, d as CommandContextExtension, f as CommandDecorator, g as CommandRunner, h as CommandLoader, i as Args, j as ValidationErrorsDecorator, k as RenderingOptions, l as CommandContext, m as CommandExamplesFetcher, n as ArgToken, o as CliOptions, p as CommandEnvironment, r as ArgValues, s as Command, t as ArgSchema, u as CommandContextCore, v as DefaultGunshiParams, w as GunshiParamsConstraint, x as ExtractArgs, y as ExtendContext } from "./types-DSyU38G8.js";
|
|
2
2
|
|
|
3
3
|
//#region src/cli/bone.d.ts
|
|
4
4
|
/**
|
package/lib/bone.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as cliCore } from "./core-
|
|
2
|
-
import { t as plugin } from "./
|
|
3
|
-
import { a as namespacedId, s as COMMON_ARGS, t as renderer } from "./src-
|
|
1
|
+
import { t as cliCore } from "./core-C9P_Gd_f.js";
|
|
2
|
+
import { t as plugin } from "./core-eN5xmB3s.js";
|
|
3
|
+
import { a as namespacedId, s as COMMON_ARGS, t as renderer } from "./src-CfO5ab2f.js";
|
|
4
4
|
|
|
5
5
|
//#region ../plugin-global/src/types.ts
|
|
6
6
|
/**
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/constants.ts
|
|
2
|
+
const ANONYMOUS_COMMAND_NAME = "(anonymous)";
|
|
3
|
+
/**
|
|
4
|
+
* A no-operation function.
|
|
5
|
+
*/
|
|
6
|
+
const NOOP = () => {};
|
|
7
|
+
const CLI_OPTIONS_DEFAULT = {
|
|
8
|
+
name: void 0,
|
|
9
|
+
description: void 0,
|
|
10
|
+
version: void 0,
|
|
11
|
+
cwd: void 0,
|
|
12
|
+
usageSilent: false,
|
|
13
|
+
subCommands: void 0,
|
|
14
|
+
leftMargin: 2,
|
|
15
|
+
middleMargin: 10,
|
|
16
|
+
usageOptionType: false,
|
|
17
|
+
usageOptionValue: true,
|
|
18
|
+
renderHeader: void 0,
|
|
19
|
+
renderUsage: void 0,
|
|
20
|
+
renderValidationErrors: void 0,
|
|
21
|
+
plugins: void 0,
|
|
22
|
+
fallbackToEntry: false
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { CLI_OPTIONS_DEFAULT as n, NOOP as r, ANONYMOUS_COMMAND_NAME as t };
|
|
@@ -1,30 +1,6 @@
|
|
|
1
|
-
import { a as log,
|
|
1
|
+
import { a as log, i as isLazyCommand, n as deepFreeze, t as create } from "./utils-DNS9AIR_.js";
|
|
2
|
+
import { n as CLI_OPTIONS_DEFAULT, r as NOOP, t as ANONYMOUS_COMMAND_NAME } from "./constants-WviiKqbt.js";
|
|
2
3
|
|
|
3
|
-
//#region src/constants.ts
|
|
4
|
-
const ANONYMOUS_COMMAND_NAME = "(anonymous)";
|
|
5
|
-
/**
|
|
6
|
-
* A no-operation function.
|
|
7
|
-
*/
|
|
8
|
-
const NOOP = () => {};
|
|
9
|
-
const CLI_OPTIONS_DEFAULT = {
|
|
10
|
-
name: void 0,
|
|
11
|
-
description: void 0,
|
|
12
|
-
version: void 0,
|
|
13
|
-
cwd: void 0,
|
|
14
|
-
usageSilent: false,
|
|
15
|
-
subCommands: void 0,
|
|
16
|
-
leftMargin: 2,
|
|
17
|
-
middleMargin: 10,
|
|
18
|
-
usageOptionType: false,
|
|
19
|
-
usageOptionValue: true,
|
|
20
|
-
renderHeader: void 0,
|
|
21
|
-
renderUsage: void 0,
|
|
22
|
-
renderValidationErrors: void 0,
|
|
23
|
-
plugins: void 0,
|
|
24
|
-
fallbackToEntry: false
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
4
|
//#region src/context.ts
|
|
29
5
|
/**
|
|
30
6
|
* The entry for gunshi context.
|
|
@@ -47,7 +23,7 @@ const CLI_OPTIONS_DEFAULT = {
|
|
|
47
23
|
* @param param - A {@link CommandContextParams | parameters} to create a command context.
|
|
48
24
|
* @returns A {@link CommandContext | command context}, which is readonly.
|
|
49
25
|
*/
|
|
50
|
-
async function createCommandContext({ args = {}, explicit = {}, values = {}, positionals = [], rest = [], argv = [], tokens = [], command = {}, extensions = {}, cliOptions = {}, callMode = "entry", omitted = false, validationError = void 0 }) {
|
|
26
|
+
async function createCommandContext({ args = {}, explicit = {}, values = {}, positionals = [], rest = [], argv = [], tokens = [], command = {}, extensions = {}, cliOptions = {}, callMode = "entry", commandPath = [], omitted = false, validationError = void 0 }) {
|
|
51
27
|
/**
|
|
52
28
|
* normailize the options schema and values, to avoid prototype pollution
|
|
53
29
|
*/
|
|
@@ -76,6 +52,7 @@ async function createCommandContext({ args = {}, explicit = {}, values = {}, pos
|
|
|
76
52
|
description: command.description,
|
|
77
53
|
omitted,
|
|
78
54
|
callMode,
|
|
55
|
+
commandPath,
|
|
79
56
|
env,
|
|
80
57
|
args: _args,
|
|
81
58
|
explicit,
|
|
@@ -113,4 +90,4 @@ function getCommandName(cmd) {
|
|
|
113
90
|
}
|
|
114
91
|
|
|
115
92
|
//#endregion
|
|
116
|
-
export {
|
|
93
|
+
export { createCommandContext as t };
|
package/lib/context.d.ts
CHANGED
|
@@ -1,3 +1,102 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
|
|
1
|
+
import { C as GunshiParams, T as LazyCommand, b as ExtractArgExplicitlyProvided, c as CommandCallMode, d as CommandContextExtension, i as Args, l as CommandContext, n as ArgToken, o as CliOptions, r as ArgValues, s as Command, v as DefaultGunshiParams, w as GunshiParamsConstraint, x as ExtractArgs, y as ExtendContext } from "./types-DSyU38G8.js";
|
|
2
|
+
|
|
3
|
+
//#region src/context.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Extract extension return types from extensions record
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
type ExtractExtensions<E extends Record<string, CommandContextExtension>> = { [K in keyof E]: E[K] extends CommandContextExtension<infer T> ? T : never };
|
|
11
|
+
/**
|
|
12
|
+
* Parameters of {@link createCommandContext}
|
|
13
|
+
*/
|
|
14
|
+
interface CommandContextParams<G extends GunshiParams | {
|
|
15
|
+
args: Args;
|
|
16
|
+
} | {
|
|
17
|
+
extensions: ExtendContext;
|
|
18
|
+
}, V extends ArgValues<ExtractArgs<G>>, C extends Command<G> | LazyCommand<G> = Command<G>, E extends Record<string, CommandContextExtension> = Record<string, CommandContextExtension>> {
|
|
19
|
+
/**
|
|
20
|
+
* An arguments of target command
|
|
21
|
+
*/
|
|
22
|
+
args?: ExtractArgs<G>;
|
|
23
|
+
/**
|
|
24
|
+
* Explicitly provided arguments
|
|
25
|
+
*/
|
|
26
|
+
explicit?: ExtractArgExplicitlyProvided<G>;
|
|
27
|
+
/**
|
|
28
|
+
* A values of target command
|
|
29
|
+
*/
|
|
30
|
+
values?: V;
|
|
31
|
+
/**
|
|
32
|
+
* A positionals arguments, which passed to the target command
|
|
33
|
+
*/
|
|
34
|
+
positionals?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* A rest arguments, which passed to the target command
|
|
37
|
+
*/
|
|
38
|
+
rest?: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Original command line arguments
|
|
41
|
+
*/
|
|
42
|
+
argv?: string[];
|
|
43
|
+
/**
|
|
44
|
+
* Argument tokens that are parsed by the `parseArgs` function
|
|
45
|
+
*/
|
|
46
|
+
tokens?: ArgToken[];
|
|
47
|
+
/**
|
|
48
|
+
* Whether the command is omitted
|
|
49
|
+
*/
|
|
50
|
+
omitted?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Command call mode.
|
|
53
|
+
*/
|
|
54
|
+
callMode?: CommandCallMode;
|
|
55
|
+
/**
|
|
56
|
+
* The path of nested sub-commands resolved to reach the current command.
|
|
57
|
+
*/
|
|
58
|
+
commandPath?: string[];
|
|
59
|
+
/**
|
|
60
|
+
* A target command
|
|
61
|
+
*/
|
|
62
|
+
command?: C;
|
|
63
|
+
/**
|
|
64
|
+
* Plugin extensions to apply as the command context extension.
|
|
65
|
+
*/
|
|
66
|
+
extensions?: E;
|
|
67
|
+
/**
|
|
68
|
+
* A command options, which is spicialized from `cli` function
|
|
69
|
+
*/
|
|
70
|
+
cliOptions?: CliOptions<G>;
|
|
71
|
+
/**
|
|
72
|
+
* Validation error from argument parsing.
|
|
73
|
+
*/
|
|
74
|
+
validationError?: AggregateError;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create a command context.
|
|
78
|
+
*
|
|
79
|
+
* @param param - A {@link CommandContextParams | parameters} to create a command context.
|
|
80
|
+
* @returns A {@link CommandContext | command context}, which is readonly.
|
|
81
|
+
*/
|
|
82
|
+
declare function createCommandContext<G extends GunshiParamsConstraint = DefaultGunshiParams, V extends ArgValues<ExtractArgs<G>> = ArgValues<ExtractArgs<G>>, C extends Command<G> | LazyCommand<G> = Command<G>, E extends Record<string, CommandContextExtension> = {}>({
|
|
83
|
+
args,
|
|
84
|
+
explicit,
|
|
85
|
+
values,
|
|
86
|
+
positionals,
|
|
87
|
+
rest,
|
|
88
|
+
argv,
|
|
89
|
+
tokens,
|
|
90
|
+
command,
|
|
91
|
+
extensions,
|
|
92
|
+
cliOptions,
|
|
93
|
+
callMode,
|
|
94
|
+
commandPath,
|
|
95
|
+
omitted,
|
|
96
|
+
validationError
|
|
97
|
+
}: CommandContextParams<G, V, C, E>): Promise<{} extends ExtractExtensions<E> ? Readonly<CommandContext<G>> : Readonly<CommandContext<GunshiParams<{
|
|
98
|
+
args: ExtractArgs<G>;
|
|
99
|
+
extensions: ExtractExtensions<E>;
|
|
100
|
+
}>>>>;
|
|
101
|
+
//#endregion
|
|
3
102
|
export { CommandContextParams, ExtractExtensions, createCommandContext };
|
package/lib/context.js
CHANGED