gunshi 0.26.2 → 0.27.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/lib/bone.d.ts +36 -0
- package/lib/bone.js +18 -0
- package/lib/cli-qFRmzDw-.js +107 -0
- package/lib/constants-5CeepucF.d.ts +8 -0
- package/lib/context-8mKhXvhZ.js +97 -0
- package/lib/context-XtGgRV6b.d.ts +93 -0
- package/lib/context.d.ts +3 -71
- package/lib/context.js +2 -2
- package/lib/core-BNheElod.js +307 -0
- package/lib/definition-BS8O9i2F.d.ts +102 -0
- package/lib/definition-Dk8cpTTh.js +31 -0
- package/lib/definition.d.ts +3 -3
- package/lib/definition.js +1 -1
- package/lib/generator.d.ts +3 -8
- package/lib/generator.js +6 -4
- package/lib/index.d.ts +88 -21
- package/lib/index.js +50 -6
- package/lib/plugin-DNwLti7p.js +50 -0
- package/lib/plugin.d.ts +4 -0
- package/lib/plugin.js +5 -0
- package/lib/renderer.d.ts +7 -16
- package/lib/renderer.js +4 -2
- package/lib/src-CYCa2B_o.js +500 -0
- package/lib/types-BOnmRdsD.d.ts +699 -0
- package/lib/utils-CgxzpzVR.js +56 -0
- package/lib/utils.d.ts +12 -0
- package/lib/utils.js +3 -0
- package/package.json +30 -11
- package/lib/cli-DVGNVw3h.js +0 -147
- package/lib/context-D_EmfRNA.js +0 -187
- package/lib/definition-CKKX4Yvy.d.ts +0 -26
- package/lib/definition-wq1Kmbvq.js +0 -29
- package/lib/locales/en-US.json +0 -15
- package/lib/locales/ja-JP.json +0 -15
- package/lib/renderer-BzRfaLdJ.js +0 -293
- package/lib/types-DtEE4hKC.d.ts +0 -441
- package/lib/utils-D41C8Abf.js +0 -103
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img width="196" src="./assets/logo.png">
|
|
2
|
+
<img alt="logo" width="196" src="./assets/logo.png">
|
|
3
3
|
</p>
|
|
4
4
|
<h1 align="center">🏯 Gunshi</h1>
|
|
5
5
|
|
|
@@ -58,7 +58,7 @@ import { cli } from 'gunshi'
|
|
|
58
58
|
const command = {
|
|
59
59
|
name: 'greet',
|
|
60
60
|
description: 'A greeting command',
|
|
61
|
-
|
|
61
|
+
args: {
|
|
62
62
|
name: {
|
|
63
63
|
type: 'string',
|
|
64
64
|
short: 'n',
|
|
@@ -102,6 +102,8 @@ About more details and usage, see [documentations](https://gunshi.dev)
|
|
|
102
102
|
- [sourcemap-publisher](https://github.com/es-tooling/sourcemap-publisher): A tool to publish sourcemaps externally and rewrite sourcemap URLs at pre-publish time
|
|
103
103
|
- [curxy](https://github.com/ryoppippi/curxy): An proxy worker for using ollama in cursor
|
|
104
104
|
- [SiteMCP](https://github.com/ryoppippi/sitemcp): Fetch an entire site and use it as an MCP Server
|
|
105
|
+
- [ccusage](https://github.com/ryoppippi/ccusage): A CLI tool for analyzing Claude Code usage from local JSONL files
|
|
106
|
+
- [varlock](https://github.com/dmno-dev/varlock): Enhanced .env file loader, using @decorator style comments to add validation, type-safety, and more
|
|
105
107
|
|
|
106
108
|
## 🙌 Contributing guidelines
|
|
107
109
|
|
|
@@ -123,7 +125,7 @@ The development of Gunshi is supported by my OSS sponsors!
|
|
|
123
125
|
|
|
124
126
|
<p align="center">
|
|
125
127
|
<a href="https://cdn.jsdelivr.net/gh/kazupon/sponsors/sponsors.svg">
|
|
126
|
-
<img src='https://cdn.jsdelivr.net/gh/kazupon/sponsors/sponsors.svg'/>
|
|
128
|
+
<img alt="sponsor" src='https://cdn.jsdelivr.net/gh/kazupon/sponsors/sponsors.svg'/>
|
|
127
129
|
</a>
|
|
128
130
|
</p>
|
|
129
131
|
|
|
@@ -135,9 +137,8 @@ The development of Gunshi is supported by my OSS sponsors!
|
|
|
135
137
|
|
|
136
138
|
[npm-version-src]: https://img.shields.io/npm/v/gunshi?style=flat
|
|
137
139
|
[npm-version-href]: https://npmjs.com/package/gunshi
|
|
138
|
-
[jsr-src]: https://jsr.io/badges/@
|
|
139
|
-
[jsr-href]: https://jsr.io/@
|
|
140
|
+
[jsr-src]: https://jsr.io/badges/@gunshi/gunshi
|
|
141
|
+
[jsr-href]: https://jsr.io/@gunshi/gunshi
|
|
140
142
|
[install-size-src]: https://pkg-size.dev/badge/install/72346
|
|
141
|
-
[install-size-href]: https://pkg-size.dev/gunshi
|
|
142
143
|
[ci-src]: https://github.com/kazupon/gunshi/actions/workflows/ci.yml/badge.svg
|
|
143
144
|
[ci-href]: https://github.com/kazupon/gunshi/actions/workflows/ci.yml
|
package/lib/bone.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ArgSchema, ArgToken, ArgValues, Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions$1 as ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, NormalizeToGunshiParams, RendererDecorator, RenderingOptions, ValidationErrorsDecorator } from "./types-BOnmRdsD.js";
|
|
2
|
+
|
|
3
|
+
//#region src/cli/bone.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Run the command.
|
|
7
|
+
* @param args Command line arguments
|
|
8
|
+
* @param entry A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
|
|
9
|
+
* @param options A {@link CliOptions | CLI options}
|
|
10
|
+
* @returns A rendered usage or undefined. if you will use {@link CliOptions.usageSilent} option, it will return rendered usage string.
|
|
11
|
+
*/
|
|
12
|
+
declare function cli<A extends Args = Args, G extends GunshiParams = {
|
|
13
|
+
args: A;
|
|
14
|
+
extensions: {};
|
|
15
|
+
}>(argv: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* Run the command.
|
|
18
|
+
* @param args Command line arguments
|
|
19
|
+
* @param entry A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
|
|
20
|
+
* @param options A {@link CliOptions | CLI options}
|
|
21
|
+
* @returns A rendered usage or undefined. if you will use {@link CliOptions.usageSilent} option, it will return rendered usage string.
|
|
22
|
+
*/
|
|
23
|
+
declare function cli<E extends ExtendContext = ExtendContext, G extends GunshiParams = {
|
|
24
|
+
args: Args;
|
|
25
|
+
extensions: E;
|
|
26
|
+
}>(argv: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
|
|
27
|
+
/**
|
|
28
|
+
* Run the command.
|
|
29
|
+
* @param args Command line arguments
|
|
30
|
+
* @param entry A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
|
|
31
|
+
* @param options A {@link CliOptions | CLI options}
|
|
32
|
+
* @returns A rendered usage or undefined. if you will use {@link CliOptions.usageSilent} option, it will return rendered usage string.
|
|
33
|
+
*/
|
|
34
|
+
declare function cli<G extends GunshiParams = DefaultGunshiParams>(argv: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { ArgSchema, ArgToken, ArgValues, Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, NormalizeToGunshiParams, RendererDecorator, RenderingOptions, ValidationErrorsDecorator, cli };
|
package/lib/bone.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "./context-8mKhXvhZ.js";
|
|
2
|
+
import "./utils-CgxzpzVR.js";
|
|
3
|
+
import { cliCore } from "./core-BNheElod.js";
|
|
4
|
+
|
|
5
|
+
//#region src/cli/bone.ts
|
|
6
|
+
/**
|
|
7
|
+
* Run the command.
|
|
8
|
+
* @param args Command line arguments
|
|
9
|
+
* @param entry A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
|
|
10
|
+
* @param options A {@link CliOptions | CLI options}
|
|
11
|
+
* @returns A rendered usage or undefined. if you will use {@link CliOptions.usageSilent} option, it will return rendered usage string.
|
|
12
|
+
*/
|
|
13
|
+
async function cli(argv, entry, options = {}) {
|
|
14
|
+
return cliCore(argv, entry, options, []);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { cli };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { cliCore } from "./core-BNheElod.js";
|
|
2
|
+
import { plugin } from "./plugin-DNwLti7p.js";
|
|
3
|
+
import { COMMON_ARGS, namespacedId, renderer } from "./src-CYCa2B_o.js";
|
|
4
|
+
|
|
5
|
+
//#region ../plugin-global/src/types.ts
|
|
6
|
+
/**
|
|
7
|
+
* The unique identifier for the global options plugin.
|
|
8
|
+
*/
|
|
9
|
+
const pluginId = namespacedId("global");
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region ../plugin-global/src/decorator.ts
|
|
13
|
+
/**
|
|
14
|
+
* Decorator function to extend the command with global options.
|
|
15
|
+
*/
|
|
16
|
+
const decorator = (baseRunner) => async (ctx) => {
|
|
17
|
+
const { values, validationError, extensions: { [pluginId]: { showVersion, showHeader, showUsage, showValidationErrors } } } = ctx;
|
|
18
|
+
if (values.version) return showVersion();
|
|
19
|
+
const buf = [];
|
|
20
|
+
const header = await showHeader();
|
|
21
|
+
if (header) buf.push(header);
|
|
22
|
+
if (values.help) {
|
|
23
|
+
const usage = await showUsage();
|
|
24
|
+
if (usage) {
|
|
25
|
+
buf.push(usage);
|
|
26
|
+
return buf.join("\n");
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (validationError) return await showValidationErrors(validationError);
|
|
31
|
+
return baseRunner(ctx);
|
|
32
|
+
};
|
|
33
|
+
var decorator_default = decorator;
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region ../plugin-global/src/extension.ts
|
|
37
|
+
function extension(ctx) {
|
|
38
|
+
return {
|
|
39
|
+
showVersion: () => {
|
|
40
|
+
const version = ctx.env.version || "unknown";
|
|
41
|
+
if (!ctx.env.usageSilent) ctx.log(version);
|
|
42
|
+
return version;
|
|
43
|
+
},
|
|
44
|
+
showHeader: async () => {
|
|
45
|
+
let header;
|
|
46
|
+
if (ctx.env.renderHeader != null) {
|
|
47
|
+
header = await ctx.env.renderHeader(ctx);
|
|
48
|
+
if (header) {
|
|
49
|
+
ctx.log(header);
|
|
50
|
+
ctx.log();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return header;
|
|
54
|
+
},
|
|
55
|
+
showUsage: async () => {
|
|
56
|
+
if (ctx.env.renderUsage != null) {
|
|
57
|
+
const usage = await ctx.env.renderUsage(ctx);
|
|
58
|
+
if (usage) {
|
|
59
|
+
ctx.log(usage);
|
|
60
|
+
return usage;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
showValidationErrors: async (error) => {
|
|
65
|
+
if (ctx.env.renderValidationErrors === null) return;
|
|
66
|
+
if (ctx.env.renderValidationErrors !== void 0) {
|
|
67
|
+
const message = await ctx.env.renderValidationErrors(ctx, error);
|
|
68
|
+
ctx.log(message);
|
|
69
|
+
return message;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region ../plugin-global/src/index.ts
|
|
77
|
+
/**
|
|
78
|
+
* global options plugin
|
|
79
|
+
*/
|
|
80
|
+
function global() {
|
|
81
|
+
return plugin({
|
|
82
|
+
id: pluginId,
|
|
83
|
+
name: "global options",
|
|
84
|
+
extension,
|
|
85
|
+
setup(ctx) {
|
|
86
|
+
for (const [name, schema] of Object.entries(COMMON_ARGS)) ctx.addGlobalOption(name, schema);
|
|
87
|
+
ctx.decorateCommand(decorator_default);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/cli/builtin.ts
|
|
94
|
+
/**
|
|
95
|
+
* Run the command.
|
|
96
|
+
* @param args Command line arguments
|
|
97
|
+
* @param entry A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
|
|
98
|
+
* @param options A {@link CliOptions | CLI options}
|
|
99
|
+
* @returns A rendered usage or undefined. if you will use {@link CliOptions.usageSilent} option, it will return rendered usage string.
|
|
100
|
+
*/
|
|
101
|
+
async function cli(argv, entry, options = {}) {
|
|
102
|
+
const builtInPlugins = [global(), renderer()];
|
|
103
|
+
return cliCore(argv, entry, options, builtInPlugins);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
export { cli };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CliOptions, DefaultGunshiParams } from "./types-BOnmRdsD.js";
|
|
2
|
+
|
|
3
|
+
//#region src/constants.d.ts
|
|
4
|
+
|
|
5
|
+
declare const ANONYMOUS_COMMAND_NAME = "(anonymous)";
|
|
6
|
+
declare const CLI_OPTIONS_DEFAULT: CliOptions<DefaultGunshiParams>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { ANONYMOUS_COMMAND_NAME as ANONYMOUS_COMMAND_NAME$1, CLI_OPTIONS_DEFAULT as CLI_OPTIONS_DEFAULT$1 };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { create, deepFreeze, isLazyCommand, log } from "./utils-CgxzpzVR.js";
|
|
2
|
+
|
|
3
|
+
//#region src/constants.ts
|
|
4
|
+
const ANONYMOUS_COMMAND_NAME = "(anonymous)";
|
|
5
|
+
const NOOP = () => {};
|
|
6
|
+
const CLI_OPTIONS_DEFAULT = {
|
|
7
|
+
name: void 0,
|
|
8
|
+
description: void 0,
|
|
9
|
+
version: void 0,
|
|
10
|
+
cwd: void 0,
|
|
11
|
+
usageSilent: false,
|
|
12
|
+
subCommands: void 0,
|
|
13
|
+
leftMargin: 2,
|
|
14
|
+
middleMargin: 10,
|
|
15
|
+
usageOptionType: false,
|
|
16
|
+
usageOptionValue: true,
|
|
17
|
+
renderHeader: void 0,
|
|
18
|
+
renderUsage: void 0,
|
|
19
|
+
renderValidationErrors: void 0,
|
|
20
|
+
plugins: void 0
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/context.ts
|
|
25
|
+
/**
|
|
26
|
+
* Create a {@link CommandContext | command context}
|
|
27
|
+
* @param param A {@link CommandContextParams | parameters} to create a {@link CommandContext | command context}
|
|
28
|
+
* @returns A {@link CommandContext | command context}, which is readonly
|
|
29
|
+
*/
|
|
30
|
+
async function createCommandContext({ args, explicit, values, positionals, rest, argv, tokens, command, extensions = {}, cliOptions, callMode = "entry", omitted = false, validationError }) {
|
|
31
|
+
/**
|
|
32
|
+
* normailize the options schema and values, to avoid prototype pollution
|
|
33
|
+
*/
|
|
34
|
+
const _args = Object.entries(args).reduce((acc, [key, value]) => {
|
|
35
|
+
acc[key] = Object.assign(create(), value);
|
|
36
|
+
return acc;
|
|
37
|
+
}, create());
|
|
38
|
+
/**
|
|
39
|
+
* setup the environment
|
|
40
|
+
*/
|
|
41
|
+
const env = Object.assign(create(), CLI_OPTIONS_DEFAULT, cliOptions);
|
|
42
|
+
/**
|
|
43
|
+
* apply Command definition's rendering option with highest priority
|
|
44
|
+
*/
|
|
45
|
+
if (command.rendering) {
|
|
46
|
+
const { header, usage, validationErrors } = command.rendering;
|
|
47
|
+
if (header !== void 0) env.renderHeader = header;
|
|
48
|
+
if (usage !== void 0) env.renderUsage = usage;
|
|
49
|
+
if (validationErrors !== void 0) env.renderValidationErrors = validationErrors;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* create the command context
|
|
53
|
+
*/
|
|
54
|
+
const core = Object.assign(create(), {
|
|
55
|
+
name: getCommandName(command),
|
|
56
|
+
description: command.description,
|
|
57
|
+
omitted,
|
|
58
|
+
callMode,
|
|
59
|
+
env,
|
|
60
|
+
args: _args,
|
|
61
|
+
explicit,
|
|
62
|
+
values,
|
|
63
|
+
positionals,
|
|
64
|
+
rest,
|
|
65
|
+
_: argv,
|
|
66
|
+
tokens,
|
|
67
|
+
toKebab: command.toKebab,
|
|
68
|
+
log: cliOptions.usageSilent ? NOOP : log,
|
|
69
|
+
validationError
|
|
70
|
+
});
|
|
71
|
+
/**
|
|
72
|
+
* extend the command context with extensions
|
|
73
|
+
*/
|
|
74
|
+
if (Object.keys(extensions).length > 0) {
|
|
75
|
+
const ext = create(null);
|
|
76
|
+
Object.defineProperty(core, "extensions", {
|
|
77
|
+
value: ext,
|
|
78
|
+
writable: false,
|
|
79
|
+
enumerable: true,
|
|
80
|
+
configurable: true
|
|
81
|
+
});
|
|
82
|
+
for (const [key, extension] of Object.entries(extensions)) {
|
|
83
|
+
ext[key] = await extension.factory(core, command);
|
|
84
|
+
if (extension.onFactory) await extension.onFactory(core, command);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const ctx = deepFreeze(core, ["extensions"]);
|
|
88
|
+
return ctx;
|
|
89
|
+
}
|
|
90
|
+
function getCommandName(cmd) {
|
|
91
|
+
if (isLazyCommand(cmd)) return cmd.commandName || cmd.name || ANONYMOUS_COMMAND_NAME;
|
|
92
|
+
else if (typeof cmd === "object") return cmd.name || ANONYMOUS_COMMAND_NAME;
|
|
93
|
+
else return ANONYMOUS_COMMAND_NAME;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
export { ANONYMOUS_COMMAND_NAME, CLI_OPTIONS_DEFAULT, NOOP, createCommandContext };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ArgToken, ArgValues, CliOptions, Command, CommandCallMode, CommandContext, CommandContextExtension, DefaultGunshiParams, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, GunshiParams, GunshiParamsConstraint, LazyCommand } from "./types-BOnmRdsD.js";
|
|
2
|
+
|
|
3
|
+
//#region src/context.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Extract extension return types from extensions record
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
type ExtractExtensions<E extends Record<string, CommandContextExtension>> = { [K in keyof E]: E[K] extends CommandContextExtension<infer T> ? T : never };
|
|
10
|
+
/**
|
|
11
|
+
* Parameters of {@link createCommandContext}
|
|
12
|
+
*/
|
|
13
|
+
interface CommandContextParams<G extends GunshiParams | {
|
|
14
|
+
extensions: ExtendContext;
|
|
15
|
+
}, V extends ArgValues<ExtractArgs<G>>, C extends Command<G> | LazyCommand<G> = Command<G>, E extends Record<string, CommandContextExtension> = Record<string, CommandContextExtension>> {
|
|
16
|
+
/**
|
|
17
|
+
* An arguments of target command
|
|
18
|
+
*/
|
|
19
|
+
args: ExtractArgs<G>;
|
|
20
|
+
/**
|
|
21
|
+
* Explicitly provided arguments
|
|
22
|
+
*/
|
|
23
|
+
explicit: ExtractArgExplicitlyProvided<G>;
|
|
24
|
+
/**
|
|
25
|
+
* A values of target command
|
|
26
|
+
*/
|
|
27
|
+
values: V;
|
|
28
|
+
/**
|
|
29
|
+
* A positionals arguments, which passed to the target command
|
|
30
|
+
*/
|
|
31
|
+
positionals: string[];
|
|
32
|
+
/**
|
|
33
|
+
* A rest arguments, which passed to the target command
|
|
34
|
+
*/
|
|
35
|
+
rest: string[];
|
|
36
|
+
/**
|
|
37
|
+
* Original command line arguments
|
|
38
|
+
*/
|
|
39
|
+
argv: string[];
|
|
40
|
+
/**
|
|
41
|
+
* Argument tokens that are parsed by the `parseArgs` function
|
|
42
|
+
*/
|
|
43
|
+
tokens: ArgToken[];
|
|
44
|
+
/**
|
|
45
|
+
* Whether the command is omitted
|
|
46
|
+
*/
|
|
47
|
+
omitted: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Command call mode.
|
|
50
|
+
*/
|
|
51
|
+
callMode: CommandCallMode;
|
|
52
|
+
/**
|
|
53
|
+
* A target command
|
|
54
|
+
*/
|
|
55
|
+
command: C;
|
|
56
|
+
/**
|
|
57
|
+
* Plugin extensions to apply as the command context extension.
|
|
58
|
+
*/
|
|
59
|
+
extensions?: E;
|
|
60
|
+
/**
|
|
61
|
+
* A command options, which is spicialized from `cli` function
|
|
62
|
+
*/
|
|
63
|
+
cliOptions: CliOptions<G>;
|
|
64
|
+
/**
|
|
65
|
+
* Validation error from argument parsing.
|
|
66
|
+
*/
|
|
67
|
+
validationError?: AggregateError;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create a {@link CommandContext | command context}
|
|
71
|
+
* @param param A {@link CommandContextParams | parameters} to create a {@link CommandContext | command context}
|
|
72
|
+
* @returns A {@link CommandContext | command context}, which is readonly
|
|
73
|
+
*/
|
|
74
|
+
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> = {}>({
|
|
75
|
+
args,
|
|
76
|
+
explicit,
|
|
77
|
+
values,
|
|
78
|
+
positionals,
|
|
79
|
+
rest,
|
|
80
|
+
argv,
|
|
81
|
+
tokens,
|
|
82
|
+
command,
|
|
83
|
+
extensions,
|
|
84
|
+
cliOptions,
|
|
85
|
+
callMode,
|
|
86
|
+
omitted,
|
|
87
|
+
validationError
|
|
88
|
+
}: CommandContextParams<G, V, C, E>): Promise<{} extends ExtractExtensions<E> ? Readonly<CommandContext<G>> : Readonly<CommandContext<GunshiParams<{
|
|
89
|
+
args: ExtractArgs<G>;
|
|
90
|
+
extensions: ExtractExtensions<E>;
|
|
91
|
+
}>>>>;
|
|
92
|
+
//#endregion
|
|
93
|
+
export { ExtractExtensions, createCommandContext as createCommandContext$1 };
|
package/lib/context.d.ts
CHANGED
|
@@ -1,71 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
//#region src/context.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Parameters of {@link createCommandContext}
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Parameters of {@link createCommandContext}
|
|
11
|
-
*/
|
|
12
|
-
interface CommandContextParams<A extends Args, V> {
|
|
13
|
-
/**
|
|
14
|
-
* An arguments of target command
|
|
15
|
-
*/
|
|
16
|
-
args: A;
|
|
17
|
-
/**
|
|
18
|
-
* A values of target command
|
|
19
|
-
*/
|
|
20
|
-
values: V;
|
|
21
|
-
/**
|
|
22
|
-
* A positionals arguments, which passed to the target command
|
|
23
|
-
*/
|
|
24
|
-
positionals: string[];
|
|
25
|
-
/**
|
|
26
|
-
* A rest arguments, which passed to the target command
|
|
27
|
-
*/
|
|
28
|
-
rest: string[];
|
|
29
|
-
/**
|
|
30
|
-
* Original command line arguments
|
|
31
|
-
*/
|
|
32
|
-
argv: string[];
|
|
33
|
-
/**
|
|
34
|
-
* Argument tokens that are parsed by the `parseArgs` function
|
|
35
|
-
*/
|
|
36
|
-
tokens: ArgToken[];
|
|
37
|
-
/**
|
|
38
|
-
* Whether the command is omitted
|
|
39
|
-
*/
|
|
40
|
-
omitted: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Command call mode.
|
|
43
|
-
*/
|
|
44
|
-
callMode: CommandCallMode;
|
|
45
|
-
/**
|
|
46
|
-
* A target command
|
|
47
|
-
*/
|
|
48
|
-
command: Command<A> | LazyCommand<A>;
|
|
49
|
-
/**
|
|
50
|
-
* A command options, which is spicialized from `cli` function
|
|
51
|
-
*/
|
|
52
|
-
cliOptions: CliOptions<A>;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Create a {@link CommandContext | command context}
|
|
56
|
-
* @param param A {@link CommandContextParams | parameters} to create a {@link CommandContext | command context}
|
|
57
|
-
* @returns A {@link CommandContext | command context}, which is readonly
|
|
58
|
-
*/
|
|
59
|
-
declare function createCommandContext<A extends Args = Args, V extends ArgValues<A> = ArgValues<A>>({
|
|
60
|
-
args,
|
|
61
|
-
values,
|
|
62
|
-
positionals,
|
|
63
|
-
rest,
|
|
64
|
-
argv,
|
|
65
|
-
tokens,
|
|
66
|
-
command,
|
|
67
|
-
cliOptions,
|
|
68
|
-
callMode,
|
|
69
|
-
omitted
|
|
70
|
-
}: CommandContextParams<A, V>): Promise<Readonly<CommandContext<A, V>>>; //#endregion
|
|
71
|
-
export { createCommandContext };
|
|
1
|
+
import "./types-BOnmRdsD.js";
|
|
2
|
+
import { ExtractExtensions, createCommandContext$1 as createCommandContext } from "./context-XtGgRV6b.js";
|
|
3
|
+
export { ExtractExtensions, createCommandContext };
|
package/lib/context.js
CHANGED