gunshi 0.18.0 → 0.20.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/README.md +1 -0
- package/lib/{cli-8GpxrUOM.js → cli-rwwoCHjK.js} +14 -11
- package/lib/{context-DSuCy-i-.js → context-IwpAqLSL.js} +12 -13
- package/lib/context.d.ts +22 -19
- package/lib/context.js +2 -2
- package/lib/definition-BrCD_SuG.d.ts +26 -0
- package/lib/{definition-DZJeZYb2.js → definition-DyVBFqB7.js} +1 -1
- package/lib/definition.d.ts +3 -3
- package/lib/definition.js +1 -1
- package/lib/generator.d.ts +10 -3
- package/lib/generator.js +4 -4
- package/lib/index.d.ts +12 -5
- package/lib/index.js +5 -5
- package/lib/locales/en-US.json +1 -0
- package/lib/locales/ja-JP.json +1 -0
- package/lib/{renderer-BgAkL9Re.js → renderer-BpwhGYRZ.js} +67 -30
- package/lib/renderer.d.ts +19 -14
- package/lib/renderer.js +2 -2
- package/lib/{types.d-BqXvgR9J.d.ts → types-iztBdPY6.d.ts} +125 -120
- package/lib/{utils-6RnUrIMZ.js → utils-STQBqMtf.js} +10 -7
- package/package.json +16 -11
- package/lib/definition.d-DaKM6lt0.d.ts +0 -21
package/README.md
CHANGED
|
@@ -99,6 +99,7 @@ About more details and usage, see [documentations](https://gunshi.dev)
|
|
|
99
99
|
## 💁♀️ Showcases
|
|
100
100
|
|
|
101
101
|
- [pnpmc](https://github.com/kazupon/pnpmc): PNPM Catalogs Tooling
|
|
102
|
+
- [sourcemap-publisher](https://github.com/es-tooling/sourcemap-publisher): A tool to publish sourcemaps externally and rewrite sourcemap URLs at pre-publish time
|
|
102
103
|
|
|
103
104
|
## 🙌 Contributing guidelines
|
|
104
105
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { COMMAND_OPTIONS_DEFAULT,
|
|
2
|
-
import { createCommandContext } from "./context-
|
|
3
|
-
import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-
|
|
1
|
+
import { COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, create, resolveLazyCommand } from "./utils-STQBqMtf.js";
|
|
2
|
+
import { createCommandContext } from "./context-IwpAqLSL.js";
|
|
3
|
+
import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-BpwhGYRZ.js";
|
|
4
4
|
import { parseArgs, resolveArgs } from "args-tokens";
|
|
5
5
|
|
|
6
6
|
//#region src/cli.ts
|
|
@@ -11,21 +11,24 @@ import { parseArgs, resolveArgs } from "args-tokens";
|
|
|
11
11
|
* @param opts A {@link CommandOptions | command options}
|
|
12
12
|
* @returns A rendered usage or undefined. if you will use {@link CommandOptions.usageSilent} option, it will return rendered usage string.
|
|
13
13
|
*/
|
|
14
|
-
async function cli(
|
|
15
|
-
const tokens = parseArgs(
|
|
14
|
+
async function cli(argv, entry, opts = {}) {
|
|
15
|
+
const tokens = parseArgs(argv);
|
|
16
16
|
const subCommand = getSubCommand(tokens);
|
|
17
17
|
const resolvedCommandOptions = resolveCommandOptions(opts, entry);
|
|
18
18
|
const [name, command] = await resolveCommand(subCommand, entry, resolvedCommandOptions, true);
|
|
19
19
|
if (!command) throw new Error(`Command not found: ${name || ""}`);
|
|
20
|
-
const
|
|
21
|
-
const { values, positionals, rest, error } = resolveArgs(
|
|
20
|
+
const args = resolveArguments(command.args);
|
|
21
|
+
const { values, positionals, rest, error } = resolveArgs(args, tokens, {
|
|
22
|
+
optionGrouping: true,
|
|
23
|
+
skipPositional: resolvedCommandOptions.subCommands.size > 0 ? 0 : -1
|
|
24
|
+
});
|
|
22
25
|
const omitted = !subCommand;
|
|
23
26
|
const ctx = await createCommandContext({
|
|
24
|
-
|
|
27
|
+
args,
|
|
25
28
|
values,
|
|
26
29
|
positionals,
|
|
27
30
|
rest,
|
|
28
|
-
|
|
31
|
+
argv,
|
|
29
32
|
tokens,
|
|
30
33
|
omitted,
|
|
31
34
|
command,
|
|
@@ -50,8 +53,8 @@ async function cli(args, entry, opts = {}) {
|
|
|
50
53
|
if (!command.run) throw new Error(`'run' not found on Command \`${name || ""}\``);
|
|
51
54
|
await command.run(ctx);
|
|
52
55
|
}
|
|
53
|
-
function
|
|
54
|
-
return Object.assign(create(), options,
|
|
56
|
+
function resolveArguments(options) {
|
|
57
|
+
return Object.assign(create(), options, COMMON_ARGS);
|
|
55
58
|
}
|
|
56
59
|
function resolveCommandOptions(options, entry) {
|
|
57
60
|
const subCommands = new Map(options.subCommands);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, DEFAULT_LOCALE$1 as DEFAULT_LOCALE, NOOP, create, deepFreeze, log, mapResourceWithBuiltinKey,
|
|
1
|
+
import { BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, DEFAULT_LOCALE$1 as DEFAULT_LOCALE, NOOP, create, deepFreeze, log, mapResourceWithBuiltinKey, resolveArgKey, resolveExamples, resolveLazyCommand } from "./utils-STQBqMtf.js";
|
|
2
2
|
|
|
3
3
|
//#region src/locales/en-US.json
|
|
4
4
|
var COMMAND = "COMMAND";
|
|
5
5
|
var COMMANDS = "COMMANDS";
|
|
6
6
|
var SUBCOMMAND = "SUBCOMMAND";
|
|
7
7
|
var USAGE = "USAGE";
|
|
8
|
+
var ARGUMENTS = "ARGUMENTS";
|
|
8
9
|
var OPTIONS = "OPTIONS";
|
|
9
10
|
var EXAMPLES = "EXAMPLES";
|
|
10
11
|
var FORMORE = "For more info, run any command with the `--help` flag:";
|
|
@@ -18,6 +19,7 @@ var en_US_default = {
|
|
|
18
19
|
COMMANDS,
|
|
19
20
|
SUBCOMMAND,
|
|
20
21
|
USAGE,
|
|
22
|
+
ARGUMENTS,
|
|
21
23
|
OPTIONS,
|
|
22
24
|
EXAMPLES,
|
|
23
25
|
FORMORE,
|
|
@@ -70,11 +72,11 @@ const BUILT_IN_PREFIX_CODE = BUILT_IN_PREFIX.codePointAt(0);
|
|
|
70
72
|
* @param param A {@link CommandContextParams | parameters} to create a {@link CommandContext | command context}
|
|
71
73
|
* @returns A {@link CommandContext | command context}, which is readonly
|
|
72
74
|
*/
|
|
73
|
-
async function createCommandContext({
|
|
75
|
+
async function createCommandContext({ args, values, positionals, rest, argv, tokens, command, commandOptions, omitted = false }) {
|
|
74
76
|
/**
|
|
75
77
|
* normailize the options schema and values, to avoid prototype pollution
|
|
76
78
|
*/
|
|
77
|
-
const
|
|
79
|
+
const _args = Object.entries(args).reduce((acc, [key, value]) => {
|
|
78
80
|
acc[key] = Object.assign(create(), value);
|
|
79
81
|
return acc;
|
|
80
82
|
}, create());
|
|
@@ -128,11 +130,11 @@ async function createCommandContext({ options, values, positionals, rest, args,
|
|
|
128
130
|
omitted,
|
|
129
131
|
locale,
|
|
130
132
|
env,
|
|
131
|
-
|
|
133
|
+
args: _args,
|
|
132
134
|
values,
|
|
133
135
|
positionals,
|
|
134
136
|
rest,
|
|
135
|
-
_:
|
|
137
|
+
_: argv,
|
|
136
138
|
tokens,
|
|
137
139
|
log: commandOptions.usageSilent ? NOOP : log,
|
|
138
140
|
loadCommands,
|
|
@@ -141,23 +143,20 @@ async function createCommandContext({ options, values, positionals, rest, args,
|
|
|
141
143
|
/**
|
|
142
144
|
* load the command resources
|
|
143
145
|
*/
|
|
144
|
-
const loadedOptionsResources = Object.entries(
|
|
145
|
-
const description =
|
|
146
|
+
const loadedOptionsResources = Object.entries(args).map(([key, arg]) => {
|
|
147
|
+
const description = arg.description || "";
|
|
146
148
|
return [key, description];
|
|
147
149
|
});
|
|
148
150
|
const defaultCommandResource = loadedOptionsResources.reduce((res, [key, value]) => {
|
|
149
|
-
res[
|
|
151
|
+
res[resolveArgKey(key)] = value;
|
|
150
152
|
return res;
|
|
151
153
|
}, create());
|
|
152
154
|
defaultCommandResource.description = command.description || "";
|
|
153
|
-
defaultCommandResource.examples = command.examples
|
|
155
|
+
defaultCommandResource.examples = await resolveExamples(ctx, command.examples);
|
|
154
156
|
adapter.setResource(DEFAULT_LOCALE, defaultCommandResource);
|
|
155
157
|
const originalResource = await loadCommandResource(ctx, command);
|
|
156
158
|
if (originalResource) {
|
|
157
|
-
const resource = Object.assign(create(), {
|
|
158
|
-
description: originalResource.description,
|
|
159
|
-
examples: originalResource.examples
|
|
160
|
-
}, originalResource);
|
|
159
|
+
const resource = Object.assign(create(), originalResource, { examples: await resolveExamples(ctx, originalResource.examples) });
|
|
161
160
|
if (builtInLoadedResources) {
|
|
162
161
|
resource.help = builtInLoadedResources.help;
|
|
163
162
|
resource.version = builtInLoadedResources.version;
|
package/lib/context.d.ts
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import { Command, CommandContext, CommandOptions } from "./types
|
|
2
|
-
import {
|
|
1
|
+
import { Command, CommandContext, CommandOptions } from "./types-iztBdPY6.js";
|
|
2
|
+
import { ArgToken, ArgValues, Args } from "args-tokens";
|
|
3
3
|
|
|
4
4
|
//#region src/context.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Parameters of {@link createCommandContext}
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Parameters of {@link createCommandContext}
|
|
11
|
+
*/
|
|
12
|
+
interface CommandContextParams<A extends Args, V> {
|
|
10
13
|
/**
|
|
11
|
-
* An
|
|
14
|
+
* An arguments of target command
|
|
12
15
|
*/
|
|
13
|
-
|
|
16
|
+
args: A;
|
|
14
17
|
/**
|
|
15
18
|
* A values of target command
|
|
16
19
|
*/
|
|
17
|
-
values:
|
|
20
|
+
values: V;
|
|
18
21
|
/**
|
|
19
22
|
* A positionals arguments, which passed to the target command
|
|
20
23
|
*/
|
|
@@ -26,7 +29,7 @@ interface CommandContextParams<Options extends ArgOptions, Values> {
|
|
|
26
29
|
/**
|
|
27
30
|
* Original command line arguments
|
|
28
31
|
*/
|
|
29
|
-
|
|
32
|
+
argv: string[];
|
|
30
33
|
/**
|
|
31
34
|
* Argument tokens that are parsed by the `parseArgs` function
|
|
32
35
|
*/
|
|
@@ -38,26 +41,26 @@ interface CommandContextParams<Options extends ArgOptions, Values> {
|
|
|
38
41
|
/**
|
|
39
42
|
* A target {@link Command | command}
|
|
40
43
|
*/
|
|
41
|
-
command: Command<
|
|
44
|
+
command: Command<A>;
|
|
42
45
|
/**
|
|
43
46
|
* A command options, which is spicialized from `cli` function
|
|
44
47
|
*/
|
|
45
|
-
commandOptions: CommandOptions<
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
declare function createCommandContext<
|
|
53
|
-
|
|
48
|
+
commandOptions: CommandOptions<A>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create a {@link CommandContext | command context}
|
|
52
|
+
* @param param A {@link CommandContextParams | parameters} to create a {@link CommandContext | command context}
|
|
53
|
+
* @returns A {@link CommandContext | command context}, which is readonly
|
|
54
|
+
*/
|
|
55
|
+
declare function createCommandContext<A extends Args = Args, V extends ArgValues<A> = ArgValues<A>>({
|
|
56
|
+
args,
|
|
54
57
|
values,
|
|
55
58
|
positionals,
|
|
56
59
|
rest,
|
|
57
|
-
|
|
60
|
+
argv,
|
|
58
61
|
tokens,
|
|
59
62
|
command,
|
|
60
63
|
commandOptions,
|
|
61
64
|
omitted
|
|
62
|
-
}: CommandContextParams<
|
|
65
|
+
}: CommandContextParams<A, V>): Promise<Readonly<CommandContext<A, V>>>; //#endregion
|
|
63
66
|
export { createCommandContext };
|
package/lib/context.js
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Command, CommandLoader, LazyCommand } from "./types-iztBdPY6.js";
|
|
2
|
+
import { ArgSchema, ArgValues as ArgValues$1, Args, Args as Args$1 } from "args-tokens";
|
|
3
|
+
|
|
4
|
+
//#region src/definition.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Define a {@link Command | command} with type inference
|
|
7
|
+
* @param definition A {@link Command | command} definition
|
|
8
|
+
* @returns A {@link Command | command} definition with type inference
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Define a {@link Command | command} with type inference
|
|
13
|
+
* @param definition A {@link Command | command} definition
|
|
14
|
+
* @returns A {@link Command | command} definition with type inference
|
|
15
|
+
*/
|
|
16
|
+
declare function define<A extends Args = Args>(definition: Command<A>): Command<A>;
|
|
17
|
+
/**
|
|
18
|
+
* Define a {@link LazyCommand | lazy command} with command loader, which is attached with command definition as usage metadata.
|
|
19
|
+
* @param loader A {@link CommandLoader | command loader}
|
|
20
|
+
* @param definition A {@link Command | command} definition
|
|
21
|
+
* @returns A {@link LazyCommand | lazy command} loader
|
|
22
|
+
*/
|
|
23
|
+
declare function lazy<A extends Args = Args>(loader: CommandLoader<A>, definition?: Command<A>): LazyCommand<A>;
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { ArgSchema, ArgValues$1 as ArgValues, Args$1 as Args, define as define$1, lazy as lazy$1 };
|
|
@@ -17,7 +17,7 @@ function lazy(loader, definition) {
|
|
|
17
17
|
if (definition != null) {
|
|
18
18
|
loader.commandName = definition.name;
|
|
19
19
|
loader.description = definition.description;
|
|
20
|
-
loader.
|
|
20
|
+
loader.args = definition.args;
|
|
21
21
|
loader.examples = definition.examples;
|
|
22
22
|
loader.resource = definition.resource;
|
|
23
23
|
}
|
package/lib/definition.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./types
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
import "./types-iztBdPY6.js";
|
|
2
|
+
import { ArgSchema, ArgValues, Args, define$1 as define, lazy$1 as lazy } from "./definition-BrCD_SuG.js";
|
|
3
|
+
export { ArgSchema, ArgValues, Args, define, lazy };
|
package/lib/definition.js
CHANGED
package/lib/generator.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Command, CommandOptions } from "./types
|
|
2
|
-
import {
|
|
1
|
+
import { Command, CommandOptions } from "./types-iztBdPY6.js";
|
|
2
|
+
import { Args } from "args-tokens";
|
|
3
3
|
|
|
4
4
|
//#region src/generator.d.ts
|
|
5
5
|
/**
|
|
@@ -10,7 +10,14 @@ import { ArgOptions } from "args-tokens";
|
|
|
10
10
|
* @returns A rendered usage.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Generate the command usage.
|
|
15
|
+
* @param command - usage generate command, if you want to generate the usage of the default command where there are target commands and sub-commands, specify `null`.
|
|
16
|
+
* @param entry - A {@link Command | entry command}
|
|
17
|
+
* @param opts - A {@link CommandOptions | command options}
|
|
18
|
+
* @returns A rendered usage.
|
|
19
|
+
*/
|
|
20
|
+
declare function generate<A extends Args = Args>(command: string | null, entry: Command<A>, opts?: CommandOptions<A>): Promise<string>;
|
|
14
21
|
|
|
15
22
|
//#endregion
|
|
16
23
|
export { generate };
|
package/lib/generator.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { create } from "./utils-
|
|
2
|
-
import "./context-
|
|
3
|
-
import "./renderer-
|
|
4
|
-
import { cli } from "./cli-
|
|
1
|
+
import { create } from "./utils-STQBqMtf.js";
|
|
2
|
+
import "./context-IwpAqLSL.js";
|
|
3
|
+
import "./renderer-BpwhGYRZ.js";
|
|
4
|
+
import { cli } from "./cli-rwwoCHjK.js";
|
|
5
5
|
|
|
6
6
|
//#region src/generator.ts
|
|
7
7
|
/**
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Command,
|
|
2
|
-
import { define$1 as define, lazy$1 as lazy } from "./definition
|
|
3
|
-
import {
|
|
1
|
+
import { Command, CommandArgKeys, CommandBuiltinArgsKeys, CommandBuiltinKeys, CommandBuiltinResourceKeys, CommandContext, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandOptions, CommandResource, CommandResourceFetcher, CommandRunner, Commandable, DEFAULT_LOCALE, GenerateNamespacedKey, KeyOfArgs, LazyCommand, RemovedIndex, TranslationAdapter, TranslationAdapterFactory, TranslationAdapterFactoryOptions } from "./types-iztBdPY6.js";
|
|
2
|
+
import { define$1 as define, lazy$1 as lazy } from "./definition-BrCD_SuG.js";
|
|
3
|
+
import { ArgSchema, ArgValues, Args, Args as Args$1, parseArgs, resolveArgs } from "args-tokens";
|
|
4
4
|
|
|
5
5
|
//#region src/cli.d.ts
|
|
6
6
|
/**
|
|
@@ -11,7 +11,14 @@ import { ArgOptionSchema, ArgOptions, ArgOptions as ArgOptions$1, ArgValues, par
|
|
|
11
11
|
* @returns A rendered usage or undefined. if you will use {@link CommandOptions.usageSilent} option, it will return rendered usage string.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Run the command.
|
|
16
|
+
* @param args Command line arguments
|
|
17
|
+
* @param entry A {@link Command | entry command} or an {@link CommandRunner | inline command runner}
|
|
18
|
+
* @param opts A {@link CommandOptions | command options}
|
|
19
|
+
* @returns A rendered usage or undefined. if you will use {@link CommandOptions.usageSilent} option, it will return rendered usage string.
|
|
20
|
+
*/
|
|
21
|
+
declare function cli<A extends Args$1 = Args$1>(argv: string[], entry: Command<A> | CommandRunner<A>, opts?: CommandOptions<A>): Promise<string | undefined>;
|
|
15
22
|
|
|
16
23
|
//#endregion
|
|
17
24
|
//#region src/translation.d.ts
|
|
@@ -25,4 +32,4 @@ declare class DefaultTranslation implements TranslationAdapter {
|
|
|
25
32
|
}
|
|
26
33
|
|
|
27
34
|
//#endregion
|
|
28
|
-
export {
|
|
35
|
+
export { ArgSchema, ArgValues, Args, Command, CommandArgKeys, CommandBuiltinArgsKeys, CommandBuiltinKeys, CommandBuiltinResourceKeys, CommandContext, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandOptions, CommandResource, CommandResourceFetcher, CommandRunner, Commandable, DEFAULT_LOCALE, DefaultTranslation, GenerateNamespacedKey, KeyOfArgs, LazyCommand, RemovedIndex, TranslationAdapter, TranslationAdapterFactory, TranslationAdapterFactoryOptions, cli, define, lazy, parseArgs, resolveArgs };
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DEFAULT_LOCALE$1 as DEFAULT_LOCALE } from "./utils-
|
|
2
|
-
import { DefaultTranslation } from "./context-
|
|
3
|
-
import { define, lazy } from "./definition-
|
|
4
|
-
import "./renderer-
|
|
5
|
-
import { cli } from "./cli-
|
|
1
|
+
import { DEFAULT_LOCALE$1 as DEFAULT_LOCALE } from "./utils-STQBqMtf.js";
|
|
2
|
+
import { DefaultTranslation } from "./context-IwpAqLSL.js";
|
|
3
|
+
import { define, lazy } from "./definition-DyVBFqB7.js";
|
|
4
|
+
import "./renderer-BpwhGYRZ.js";
|
|
5
|
+
import { cli } from "./cli-rwwoCHjK.js";
|
|
6
6
|
import { parseArgs, resolveArgs } from "args-tokens";
|
|
7
7
|
|
|
8
8
|
export { DEFAULT_LOCALE, DefaultTranslation, cli, define, lazy, parseArgs, resolveArgs };
|
package/lib/locales/en-US.json
CHANGED
package/lib/locales/ja-JP.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { COMMON_ARGS, create, resolveArgKey, resolveBuiltInKey, resolveExamples } from "./utils-STQBqMtf.js";
|
|
2
2
|
|
|
3
3
|
//#region src/renderer/header.ts
|
|
4
4
|
/**
|
|
@@ -13,7 +13,7 @@ function renderHeader(ctx) {
|
|
|
13
13
|
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/renderer/usage.ts
|
|
16
|
-
const
|
|
16
|
+
const COMMON_ARGS_KEYS = Object.keys(COMMON_ARGS);
|
|
17
17
|
/**
|
|
18
18
|
* Render the usage.
|
|
19
19
|
* @param ctx A {@link CommandContext | command context}
|
|
@@ -27,20 +27,32 @@ async function renderUsage(ctx) {
|
|
|
27
27
|
}
|
|
28
28
|
messages.push(...await renderUsageSection(ctx), "");
|
|
29
29
|
if (ctx.omitted && await hasCommands(ctx)) messages.push(...await renderCommandsSection(ctx), "");
|
|
30
|
-
if (
|
|
31
|
-
|
|
30
|
+
if (hasPositionalArgs(ctx)) messages.push(...await renderPositionalArgsSection(ctx), "");
|
|
31
|
+
if (hasOptionalArgs(ctx)) messages.push(...await renderOptionalArgsSection(ctx), "");
|
|
32
|
+
const examples = await renderExamplesSection(ctx);
|
|
32
33
|
if (examples.length > 0) messages.push(...examples, "");
|
|
33
34
|
return messages.join("\n");
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
|
-
* Render the
|
|
37
|
+
* Render the positional arguments section
|
|
38
|
+
* @param ctx A {@link CommandContext | command context}
|
|
39
|
+
* @returns A rendered arguments section
|
|
40
|
+
*/
|
|
41
|
+
async function renderPositionalArgsSection(ctx) {
|
|
42
|
+
const messages = [];
|
|
43
|
+
messages.push(`${ctx.translate(resolveBuiltInKey("ARGUMENTS"))}:`);
|
|
44
|
+
messages.push(await generatePositionalArgsUsage(ctx));
|
|
45
|
+
return messages;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Render the optional arguments section
|
|
37
49
|
* @param ctx A {@link CommandContext | command context}
|
|
38
50
|
* @returns A rendered options section
|
|
39
51
|
*/
|
|
40
|
-
async function
|
|
52
|
+
async function renderOptionalArgsSection(ctx) {
|
|
41
53
|
const messages = [];
|
|
42
54
|
messages.push(`${ctx.translate(resolveBuiltInKey("OPTIONS"))}:`);
|
|
43
|
-
messages.push(await
|
|
55
|
+
messages.push(await generateOptionalArgsUsage(ctx, getOptionalArgsPairs(ctx)));
|
|
44
56
|
return messages;
|
|
45
57
|
}
|
|
46
58
|
/**
|
|
@@ -48,9 +60,9 @@ async function renderOptionsSection(ctx) {
|
|
|
48
60
|
* @param ctx A {@link CommandContext | command context}
|
|
49
61
|
* @returns A rendered examples section
|
|
50
62
|
*/
|
|
51
|
-
function renderExamplesSection(ctx) {
|
|
63
|
+
async function renderExamplesSection(ctx) {
|
|
52
64
|
const messages = [];
|
|
53
|
-
const resolvedExamples = resolveExamples(ctx);
|
|
65
|
+
const resolvedExamples = await resolveExamples$1(ctx);
|
|
54
66
|
if (resolvedExamples) {
|
|
55
67
|
const examples = resolvedExamples.split("\n").map((example) => example.padStart(ctx.env.leftMargin + example.length));
|
|
56
68
|
messages.push(`${ctx.translate(resolveBuiltInKey("EXAMPLES"))}:`, ...examples);
|
|
@@ -65,14 +77,14 @@ function renderExamplesSection(ctx) {
|
|
|
65
77
|
async function renderUsageSection(ctx) {
|
|
66
78
|
const messages = [`${ctx.translate(resolveBuiltInKey("USAGE"))}:`];
|
|
67
79
|
if (ctx.omitted) {
|
|
68
|
-
const defaultCommand = `${resolveEntry(ctx)}${await hasCommands(ctx) ? ` [${resolveSubCommand(ctx)}]` : ""} ${
|
|
80
|
+
const defaultCommand = `${resolveEntry(ctx)}${await hasCommands(ctx) ? ` [${resolveSubCommand(ctx)}]` : ""} ${[generateOptionsSymbols(ctx), generatePositionalSymbols(ctx)].filter(Boolean).join(" ")}`;
|
|
69
81
|
messages.push(defaultCommand.padStart(ctx.env.leftMargin + defaultCommand.length));
|
|
70
82
|
if (await hasCommands(ctx)) {
|
|
71
83
|
const commandsUsage = `${resolveEntry(ctx)} <${ctx.translate(resolveBuiltInKey("COMMANDS"))}>`;
|
|
72
84
|
messages.push(commandsUsage.padStart(ctx.env.leftMargin + commandsUsage.length));
|
|
73
85
|
}
|
|
74
86
|
} else {
|
|
75
|
-
const usageStr = `${resolveEntry(ctx)} ${resolveSubCommand(ctx)} ${generateOptionsSymbols(ctx)}`;
|
|
87
|
+
const usageStr = `${resolveEntry(ctx)} ${resolveSubCommand(ctx)} ${[generateOptionsSymbols(ctx), generatePositionalSymbols(ctx)].filter(Boolean).join(" ")}`;
|
|
76
88
|
messages.push(usageStr.padStart(ctx.env.leftMargin + usageStr.length));
|
|
77
89
|
}
|
|
78
90
|
return messages;
|
|
@@ -128,11 +140,11 @@ function resolveDescription(ctx) {
|
|
|
128
140
|
* @param ctx A {@link CommandContext | command context}
|
|
129
141
|
* @returns resolved command examples, if not resolved, return empty string
|
|
130
142
|
*/
|
|
131
|
-
function resolveExamples(ctx) {
|
|
143
|
+
async function resolveExamples$1(ctx) {
|
|
132
144
|
const ret = ctx.translate("examples");
|
|
133
145
|
if (ret) return ret;
|
|
134
146
|
const command = ctx.env.subCommands?.get(ctx.name || "");
|
|
135
|
-
return command?.examples
|
|
147
|
+
return await resolveExamples(ctx, command?.examples);
|
|
136
148
|
}
|
|
137
149
|
/**
|
|
138
150
|
* Check if the command has sub commands
|
|
@@ -144,12 +156,20 @@ async function hasCommands(ctx) {
|
|
|
144
156
|
return loadedCommands.length > 1;
|
|
145
157
|
}
|
|
146
158
|
/**
|
|
147
|
-
* Check if the command has
|
|
159
|
+
* Check if the command has optional arguments
|
|
160
|
+
* @param ctx A {@link CommandContext | command context}
|
|
161
|
+
* @returns True if the command has options
|
|
162
|
+
*/
|
|
163
|
+
function hasOptionalArgs(ctx) {
|
|
164
|
+
return !!(ctx.args && Object.values(ctx.args).some((arg) => arg.type !== "positional"));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Check if the command has positional arguments
|
|
148
168
|
* @param ctx A {@link CommandContext | command context}
|
|
149
169
|
* @returns True if the command has options
|
|
150
170
|
*/
|
|
151
|
-
function
|
|
152
|
-
return !!(ctx.
|
|
171
|
+
function hasPositionalArgs(ctx) {
|
|
172
|
+
return !!(ctx.args && Object.values(ctx.args).some((arg) => arg.type === "positional"));
|
|
153
173
|
}
|
|
154
174
|
/**
|
|
155
175
|
* Check if all options have default values
|
|
@@ -157,7 +177,7 @@ function hasOptions(ctx) {
|
|
|
157
177
|
* @returns True if all options have default values
|
|
158
178
|
*/
|
|
159
179
|
function hasAllDefaultOptions(ctx) {
|
|
160
|
-
return !!(ctx.
|
|
180
|
+
return !!(ctx.args && Object.values(ctx.args).every((arg) => arg.default));
|
|
161
181
|
}
|
|
162
182
|
/**
|
|
163
183
|
* Generate options symbols for usage
|
|
@@ -165,7 +185,7 @@ function hasAllDefaultOptions(ctx) {
|
|
|
165
185
|
* @returns Options symbols for usage
|
|
166
186
|
*/
|
|
167
187
|
function generateOptionsSymbols(ctx) {
|
|
168
|
-
return
|
|
188
|
+
return hasOptionalArgs(ctx) ? hasAllDefaultOptions(ctx) ? `[${ctx.translate(resolveBuiltInKey("OPTIONS"))}]` : `<${ctx.translate(resolveBuiltInKey("OPTIONS"))}>` : "";
|
|
169
189
|
}
|
|
170
190
|
function makeShortLongOptionPair(schema, name) {
|
|
171
191
|
let key = `--${name}`;
|
|
@@ -173,29 +193,30 @@ function makeShortLongOptionPair(schema, name) {
|
|
|
173
193
|
return key;
|
|
174
194
|
}
|
|
175
195
|
/**
|
|
176
|
-
* Get
|
|
196
|
+
* Get optional arguments pairs for usage
|
|
177
197
|
* @param ctx A {@link CommandContext | command context}
|
|
178
198
|
* @returns Options pairs for usage
|
|
179
199
|
*/
|
|
180
|
-
function
|
|
181
|
-
return Object.entries(ctx.
|
|
200
|
+
function getOptionalArgsPairs(ctx) {
|
|
201
|
+
return Object.entries(ctx.args).reduce((acc, [name, value]) => {
|
|
202
|
+
if (value.type === "positional") return acc;
|
|
182
203
|
let key = makeShortLongOptionPair(value, name);
|
|
183
204
|
if (value.type !== "boolean") key = value.default ? `${key} [${name}]` : `${key} <${name}>`;
|
|
184
205
|
acc[name] = key;
|
|
185
|
-
if (value.type === "boolean" && value.negatable && !
|
|
206
|
+
if (value.type === "boolean" && value.negatable && !COMMON_ARGS_KEYS.includes(name)) acc[`no-${name}`] = `--no-${name}`;
|
|
186
207
|
return acc;
|
|
187
208
|
}, create());
|
|
188
209
|
}
|
|
189
210
|
const resolveNegatableKey = (key) => key.split("no-")[1];
|
|
190
211
|
function resolveNegatableType(key, ctx) {
|
|
191
|
-
return ctx.
|
|
212
|
+
return ctx.args[key.startsWith("no-") ? resolveNegatableKey(key) : key].type;
|
|
192
213
|
}
|
|
193
214
|
function generateDefaultDisplayValue(ctx, schema) {
|
|
194
215
|
return `${ctx.translate(resolveBuiltInKey("DEFAULT"))}: ${schema.default}`;
|
|
195
216
|
}
|
|
196
217
|
function resolveDisplayValue(ctx, key) {
|
|
197
|
-
if (
|
|
198
|
-
const schema = ctx.
|
|
218
|
+
if (COMMON_ARGS_KEYS.includes(key)) return "";
|
|
219
|
+
const schema = ctx.args[key];
|
|
199
220
|
if ((schema.type === "boolean" || schema.type === "number" || schema.type === "string") && schema.default !== void 0) return `(${generateDefaultDisplayValue(ctx, schema)})`;
|
|
200
221
|
if (schema.type === "enum") {
|
|
201
222
|
const _default = schema.default !== void 0 ? generateDefaultDisplayValue(ctx, schema) : "";
|
|
@@ -205,19 +226,19 @@ function resolveDisplayValue(ctx, key) {
|
|
|
205
226
|
return "";
|
|
206
227
|
}
|
|
207
228
|
/**
|
|
208
|
-
* Generate
|
|
229
|
+
* Generate optional arguments usage
|
|
209
230
|
* @param ctx A {@link CommandContext | command context}
|
|
210
231
|
* @param optionsPairs Options pairs for usage
|
|
211
232
|
* @returns Generated options usage
|
|
212
233
|
*/
|
|
213
|
-
async function
|
|
234
|
+
async function generateOptionalArgsUsage(ctx, optionsPairs) {
|
|
214
235
|
const optionsMaxLength = Math.max(...Object.entries(optionsPairs).map(([_, value]) => value.length));
|
|
215
|
-
const optionSchemaMaxLength = ctx.env.usageOptionType ? Math.max(...Object.entries(optionsPairs).map(([key
|
|
236
|
+
const optionSchemaMaxLength = ctx.env.usageOptionType ? Math.max(...Object.entries(optionsPairs).map(([key]) => resolveNegatableType(key, ctx).length)) : 0;
|
|
216
237
|
const usages = await Promise.all(Object.entries(optionsPairs).map(([key, value]) => {
|
|
217
|
-
let rawDesc = ctx.translate(
|
|
238
|
+
let rawDesc = ctx.translate(resolveArgKey(key));
|
|
218
239
|
if (!rawDesc && key.startsWith("no-")) {
|
|
219
240
|
const name = resolveNegatableKey(key);
|
|
220
|
-
const schema = ctx.
|
|
241
|
+
const schema = ctx.args[name];
|
|
221
242
|
const optionKey = makeShortLongOptionPair(schema, name);
|
|
222
243
|
rawDesc = `${ctx.translate(resolveBuiltInKey("NEGATABLE"))} ${optionKey}`;
|
|
223
244
|
}
|
|
@@ -229,6 +250,22 @@ async function generateOptionsUsage(ctx, optionsPairs) {
|
|
|
229
250
|
}));
|
|
230
251
|
return usages.join("\n");
|
|
231
252
|
}
|
|
253
|
+
function getPositionalArgs(ctx) {
|
|
254
|
+
return Object.entries(ctx.args).filter(([_, schema]) => schema.type === "positional");
|
|
255
|
+
}
|
|
256
|
+
async function generatePositionalArgsUsage(ctx) {
|
|
257
|
+
const positionals = getPositionalArgs(ctx);
|
|
258
|
+
const argsMaxLength = Math.max(...positionals.map(([name]) => name.length));
|
|
259
|
+
const usages = await Promise.all(positionals.map(([name]) => {
|
|
260
|
+
const desc = ctx.translate(resolveArgKey(name)) || ctx.args[name].description || "";
|
|
261
|
+
const arg = `${name.padEnd(argsMaxLength + ctx.env.middleMargin)} ${desc}`;
|
|
262
|
+
return `${arg.padStart(ctx.env.leftMargin + arg.length)}`;
|
|
263
|
+
}));
|
|
264
|
+
return usages.join("\n");
|
|
265
|
+
}
|
|
266
|
+
function generatePositionalSymbols(ctx) {
|
|
267
|
+
return hasPositionalArgs(ctx) ? getPositionalArgs(ctx).map(([name]) => `<${name}>`).join(" ") : "";
|
|
268
|
+
}
|
|
232
269
|
|
|
233
270
|
//#endregion
|
|
234
271
|
//#region src/renderer/validation.ts
|
package/lib/renderer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CommandContext } from "./types
|
|
2
|
-
import {
|
|
1
|
+
import { CommandContext } from "./types-iztBdPY6.js";
|
|
2
|
+
import { Args } from "args-tokens";
|
|
3
3
|
|
|
4
4
|
//#region src/renderer/header.d.ts
|
|
5
5
|
/**
|
|
@@ -8,26 +8,31 @@ import { ArgOptions } from "args-tokens";
|
|
|
8
8
|
* @returns A rendered header.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Render the header.
|
|
13
|
+
* @param ctx A {@link CommandContext | command context}
|
|
14
|
+
* @returns A rendered header.
|
|
15
|
+
*/
|
|
16
|
+
declare function renderHeader<A extends Args = Args>(ctx: Readonly<CommandContext<A>>): Promise<string>;
|
|
12
17
|
|
|
13
18
|
//#endregion
|
|
14
19
|
//#region src/renderer/usage.d.ts
|
|
15
20
|
/**
|
|
16
|
-
* Render the usage.
|
|
17
|
-
* @param ctx A {@link CommandContext | command context}
|
|
18
|
-
* @returns A rendered usage.
|
|
19
|
-
*/
|
|
20
|
-
declare function renderUsage<
|
|
21
|
+
* Render the usage.
|
|
22
|
+
* @param ctx A {@link CommandContext | command context}
|
|
23
|
+
* @returns A rendered usage.
|
|
24
|
+
*/
|
|
25
|
+
declare function renderUsage<A extends Args = Args>(ctx: Readonly<CommandContext<A>>): Promise<string>;
|
|
21
26
|
|
|
22
27
|
//#endregion
|
|
23
28
|
//#region src/renderer/validation.d.ts
|
|
24
29
|
/**
|
|
25
|
-
* Render the validation errors.
|
|
26
|
-
* @param ctx A {@link CommandContext | command context}
|
|
27
|
-
* @param error An {@link AggregateError} of option in `args-token` validation
|
|
28
|
-
* @returns A rendered validation error.
|
|
29
|
-
*/
|
|
30
|
-
declare function renderValidationErrors<
|
|
30
|
+
* Render the validation errors.
|
|
31
|
+
* @param ctx A {@link CommandContext | command context}
|
|
32
|
+
* @param error An {@link AggregateError} of option in `args-token` validation
|
|
33
|
+
* @returns A rendered validation error.
|
|
34
|
+
*/
|
|
35
|
+
declare function renderValidationErrors<A extends Args = Args>(_ctx: CommandContext<A>, error: AggregateError): Promise<string>;
|
|
31
36
|
|
|
32
37
|
//#endregion
|
|
33
38
|
export { renderHeader, renderUsage, renderValidationErrors };
|
package/lib/renderer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./utils-
|
|
2
|
-
import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-
|
|
1
|
+
import "./utils-STQBqMtf.js";
|
|
2
|
+
import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-BpwhGYRZ.js";
|
|
3
3
|
|
|
4
4
|
export { renderHeader, renderUsage, renderValidationErrors };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ArgToken, ArgValues, Args } from "args-tokens";
|
|
2
2
|
|
|
3
3
|
//#region rolldown:runtime
|
|
4
4
|
declare namespace constants_d_exports {
|
|
5
|
-
export { BUILT_IN_KEY_SEPARATOR, BUILT_IN_PREFIX, COMMAND_BUILTIN_RESOURCE_KEYS, COMMAND_OPTIONS_DEFAULT,
|
|
5
|
+
export { ARG_PREFIX, BUILT_IN_KEY_SEPARATOR, BUILT_IN_PREFIX, COMMAND_BUILTIN_RESOURCE_KEYS, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, DEFAULT_LOCALE, NOOP };
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* The default locale string, which format is BCP 47 language tag.
|
|
9
|
-
*/
|
|
8
|
+
* The default locale string, which format is BCP 47 language tag.
|
|
9
|
+
*/
|
|
10
10
|
declare const DEFAULT_LOCALE = "en-US";
|
|
11
11
|
declare const BUILT_IN_PREFIX = "_";
|
|
12
|
-
declare const
|
|
12
|
+
declare const ARG_PREFIX = "arg";
|
|
13
13
|
declare const BUILT_IN_KEY_SEPARATOR = ":";
|
|
14
14
|
declare const NOOP: () => void;
|
|
15
|
-
type
|
|
15
|
+
type CommonArgType = {
|
|
16
16
|
readonly help: {
|
|
17
17
|
readonly type: 'boolean';
|
|
18
18
|
readonly short: 'h';
|
|
@@ -24,52 +24,52 @@ type CommonOptionType = {
|
|
|
24
24
|
readonly description: string;
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
-
declare const
|
|
28
|
-
declare const COMMAND_OPTIONS_DEFAULT: CommandOptions<
|
|
29
|
-
declare const COMMAND_BUILTIN_RESOURCE_KEYS: readonly ["USAGE", "COMMAND", "SUBCOMMAND", "COMMANDS", "OPTIONS", "EXAMPLES", "FORMORE", "NEGATABLE", "DEFAULT", "CHOICES"];
|
|
27
|
+
declare const COMMON_ARGS: CommonArgType;
|
|
28
|
+
declare const COMMAND_OPTIONS_DEFAULT: CommandOptions<Args>;
|
|
29
|
+
declare const COMMAND_BUILTIN_RESOURCE_KEYS: readonly ["USAGE", "COMMAND", "SUBCOMMAND", "COMMANDS", "ARGUMENTS", "OPTIONS", "EXAMPLES", "FORMORE", "NEGATABLE", "DEFAULT", "CHOICES"];
|
|
30
30
|
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region src/types.d.ts
|
|
33
33
|
type Awaitable<T> = T | Promise<T>;
|
|
34
34
|
type RemoveIndexSignature<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K] };
|
|
35
|
-
|
|
36
35
|
/**
|
|
37
|
-
* Remove index signature from object or record type.
|
|
38
|
-
|
|
36
|
+
* Remove index signature from object or record type.
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
39
|
type RemovedIndex<T> = RemoveIndexSignature<{ [K in keyof T]: T[K] }>;
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
/** @internal */
|
|
41
|
+
type KeyOfArgs<A extends Args> = keyof A | { [K in keyof A]: A[K]['type'] extends 'boolean' ? A[K]['negatable'] extends true ? `no-${Extract<K, string>}` : never : never }[keyof A];
|
|
42
42
|
/**
|
|
43
|
-
* Generate a namespaced key.
|
|
44
|
-
|
|
43
|
+
* Generate a namespaced key.
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
45
46
|
type GenerateNamespacedKey<Key extends string, Prefixed extends string = typeof BUILT_IN_PREFIX> = `${Prefixed}${typeof BUILT_IN_KEY_SEPARATOR}${Key}`;
|
|
46
|
-
|
|
47
47
|
/**
|
|
48
|
-
* Command i18n built-in
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
* Command i18n built-in arguments keys.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
type CommandBuiltinArgsKeys = keyof (typeof constants_d_exports)['COMMON_ARGS'];
|
|
52
52
|
/**
|
|
53
|
-
* Command i18n built-in resource keys.
|
|
54
|
-
|
|
53
|
+
* Command i18n built-in resource keys.
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
55
56
|
type CommandBuiltinResourceKeys = (typeof constants_d_exports)['COMMAND_BUILTIN_RESOURCE_KEYS'][number];
|
|
56
|
-
|
|
57
57
|
/**
|
|
58
|
-
* Command i18n built-in keys.
|
|
59
|
-
* The command i18n built-in keys are used to {@link CommandContext.translate | translate} function.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
* Command i18n built-in keys.
|
|
59
|
+
* The command i18n built-in keys are used to {@link CommandContext.translate | translate} function.
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
type CommandBuiltinKeys = GenerateNamespacedKey<CommandBuiltinArgsKeys> | GenerateNamespacedKey<CommandBuiltinResourceKeys> | 'description' | 'examples';
|
|
63
63
|
/**
|
|
64
|
-
* Command i18n option keys.
|
|
65
|
-
* The command i18n option keys are used to {@link CommandContext.translate | translate} function.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
* Command i18n option keys.
|
|
65
|
+
* The command i18n option keys are used to {@link CommandContext.translate | translate} function.
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
type CommandArgKeys<A extends Args> = GenerateNamespacedKey<KeyOfArgs<RemovedIndex<A>>, typeof ARG_PREFIX>;
|
|
69
69
|
/**
|
|
70
|
-
* Command environment.
|
|
71
|
-
*/
|
|
72
|
-
interface CommandEnvironment<
|
|
70
|
+
* Command environment.
|
|
71
|
+
*/
|
|
72
|
+
interface CommandEnvironment<A extends Args = Args> {
|
|
73
73
|
/**
|
|
74
74
|
* Current working directory.
|
|
75
75
|
* @see {@link CommandOptions.cwd}
|
|
@@ -129,21 +129,20 @@ interface CommandEnvironment<Options extends ArgOptions = ArgOptions> {
|
|
|
129
129
|
/**
|
|
130
130
|
* Render function the command usage.
|
|
131
131
|
*/
|
|
132
|
-
renderUsage: ((ctx: CommandContext<
|
|
132
|
+
renderUsage: ((ctx: CommandContext<A>) => Promise<string>) | null | undefined;
|
|
133
133
|
/**
|
|
134
134
|
* Render function the header section in the command usage.
|
|
135
135
|
*/
|
|
136
|
-
renderHeader: ((ctx: CommandContext<
|
|
136
|
+
renderHeader: ((ctx: CommandContext<A>) => Promise<string>) | null | undefined;
|
|
137
137
|
/**
|
|
138
138
|
* Render function the validation errors.
|
|
139
139
|
*/
|
|
140
|
-
renderValidationErrors: ((ctx: CommandContext<
|
|
140
|
+
renderValidationErrors: ((ctx: CommandContext<A>, error: AggregateError) => Promise<string>) | null | undefined;
|
|
141
141
|
}
|
|
142
|
-
|
|
143
142
|
/**
|
|
144
|
-
* Command options.
|
|
145
|
-
*/
|
|
146
|
-
interface CommandOptions<
|
|
143
|
+
* Command options.
|
|
144
|
+
*/
|
|
145
|
+
interface CommandOptions<A extends Args = Args> {
|
|
147
146
|
/**
|
|
148
147
|
* Current working directory.
|
|
149
148
|
*/
|
|
@@ -178,11 +177,11 @@ interface CommandOptions<Options extends ArgOptions = ArgOptions> {
|
|
|
178
177
|
*/
|
|
179
178
|
middleMargin?: number;
|
|
180
179
|
/**
|
|
181
|
-
* Whether to display the usage
|
|
180
|
+
* Whether to display the usage optional argument type.
|
|
182
181
|
*/
|
|
183
182
|
usageOptionType?: boolean;
|
|
184
183
|
/**
|
|
185
|
-
* Whether to display the
|
|
184
|
+
* Whether to display the optional argument value.
|
|
186
185
|
*/
|
|
187
186
|
usageOptionValue?: boolean;
|
|
188
187
|
/**
|
|
@@ -192,25 +191,25 @@ interface CommandOptions<Options extends ArgOptions = ArgOptions> {
|
|
|
192
191
|
/**
|
|
193
192
|
* Render function the command usage.
|
|
194
193
|
*/
|
|
195
|
-
renderUsage?: ((ctx: Readonly<CommandContext<
|
|
194
|
+
renderUsage?: ((ctx: Readonly<CommandContext<A>>) => Promise<string>) | null;
|
|
196
195
|
/**
|
|
197
196
|
* Render function the header section in the command usage.
|
|
198
197
|
*/
|
|
199
|
-
renderHeader?: ((ctx: Readonly<CommandContext<
|
|
198
|
+
renderHeader?: ((ctx: Readonly<CommandContext<A>>) => Promise<string>) | null;
|
|
200
199
|
/**
|
|
201
200
|
* Render function the validation errors.
|
|
202
201
|
*/
|
|
203
|
-
renderValidationErrors?: ((ctx: Readonly<CommandContext<
|
|
202
|
+
renderValidationErrors?: ((ctx: Readonly<CommandContext<A>>, error: AggregateError) => Promise<string>) | null;
|
|
204
203
|
/**
|
|
205
204
|
* Translation adapter factory.
|
|
206
205
|
*/
|
|
207
206
|
translationAdapterFactory?: TranslationAdapterFactory;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
interface CommandContext<
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Command context.
|
|
210
|
+
* Command context is the context of the command execution.
|
|
211
|
+
*/
|
|
212
|
+
interface CommandContext<A extends Args = Args, V = ArgValues<A>> {
|
|
214
213
|
/**
|
|
215
214
|
* Command name, that is the command that is executed.
|
|
216
215
|
* The command name is same {@link CommandEnvironment.name}.
|
|
@@ -229,17 +228,17 @@ interface CommandContext<Options extends ArgOptions = ArgOptions, Values = ArgVa
|
|
|
229
228
|
* Command environment, that is the environment of the command that is executed.
|
|
230
229
|
* The command environment is same {@link CommandEnvironment}.
|
|
231
230
|
*/
|
|
232
|
-
env: Readonly<CommandEnvironment<
|
|
231
|
+
env: Readonly<CommandEnvironment<A>>;
|
|
233
232
|
/**
|
|
234
|
-
* Command
|
|
235
|
-
* The command
|
|
233
|
+
* Command arguments, that is the arguments of the command that is executed.
|
|
234
|
+
* The command arguments is same {@link Command.args}.
|
|
236
235
|
*/
|
|
237
|
-
|
|
236
|
+
args: A;
|
|
238
237
|
/**
|
|
239
238
|
* Command values, that is the values of the command that is executed.
|
|
240
|
-
* Resolve values with `resolveArgs` from command arguments and {@link Command.
|
|
239
|
+
* Resolve values with `resolveArgs` from command arguments and {@link Command.args}.
|
|
241
240
|
*/
|
|
242
|
-
values:
|
|
241
|
+
values: V;
|
|
243
242
|
/**
|
|
244
243
|
* Command positionals arguments, that is the positionals of the command that is executed.
|
|
245
244
|
* Resolve positionals with `resolveArgs` from command arguments.
|
|
@@ -274,19 +273,19 @@ interface CommandContext<Options extends ArgOptions = ArgOptions, Values = ArgVa
|
|
|
274
273
|
* The loaded commands are cached and returned when called again.
|
|
275
274
|
* @returns loaded commands.
|
|
276
275
|
*/
|
|
277
|
-
loadCommands: () => Promise<Command<
|
|
276
|
+
loadCommands: () => Promise<Command<A>[]>;
|
|
278
277
|
/**
|
|
279
278
|
* Translate function.
|
|
280
279
|
* @param key the key to be translated
|
|
281
280
|
* @param values the values to be formatted
|
|
282
281
|
* @returns A translated string.
|
|
283
282
|
*/
|
|
284
|
-
translate: <T extends string = CommandBuiltinKeys, O =
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
interface Command<
|
|
283
|
+
translate: <T extends string = CommandBuiltinKeys, O = CommandArgKeys<A>, K = CommandBuiltinKeys | O | T>(key: K, values?: Record<string, unknown>) => string;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Command interface.
|
|
287
|
+
*/
|
|
288
|
+
interface Command<A extends Args = Args> {
|
|
290
289
|
/**
|
|
291
290
|
* Command name.
|
|
292
291
|
* It's used to find command line arguments to execute from sub commands, and it's recommended to specify.
|
|
@@ -298,28 +297,28 @@ interface Command<Options extends ArgOptions = ArgOptions> {
|
|
|
298
297
|
*/
|
|
299
298
|
description?: string;
|
|
300
299
|
/**
|
|
301
|
-
* Command
|
|
302
|
-
* Each
|
|
300
|
+
* Command arguments.
|
|
301
|
+
* Each argument can include a description property to describe the argument in usage.
|
|
303
302
|
*/
|
|
304
|
-
|
|
303
|
+
args?: A;
|
|
305
304
|
/**
|
|
306
305
|
* Command examples.
|
|
307
306
|
* examples of how to use the command.
|
|
308
307
|
*/
|
|
309
|
-
examples?: string
|
|
308
|
+
examples?: string | CommandExamplesFetcher<A>;
|
|
310
309
|
/**
|
|
311
310
|
* Command runner. it's the command to be executed
|
|
312
311
|
*/
|
|
313
|
-
run?: CommandRunner<
|
|
312
|
+
run?: CommandRunner<A>;
|
|
314
313
|
/**
|
|
315
314
|
* Command resource fetcher.
|
|
316
315
|
*/
|
|
317
|
-
resource?: CommandResourceFetcher<
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
type CommandResource<
|
|
316
|
+
resource?: CommandResourceFetcher<A>;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Command resource.
|
|
320
|
+
*/
|
|
321
|
+
type CommandResource<A extends Args = Args> = {
|
|
323
322
|
/**
|
|
324
323
|
* Command description.
|
|
325
324
|
*/
|
|
@@ -327,23 +326,29 @@ type CommandResource<Options extends ArgOptions = ArgOptions> = {
|
|
|
327
326
|
/**
|
|
328
327
|
* Examples usage.
|
|
329
328
|
*/
|
|
330
|
-
examples: string
|
|
331
|
-
} & { [
|
|
329
|
+
examples: string | CommandExamplesFetcher<A>;
|
|
330
|
+
} & { [Arg in GenerateNamespacedKey<KeyOfArgs<RemovedIndex<A>>, typeof ARG_PREFIX>]: string } & {
|
|
332
331
|
[key: string]: string;
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
type
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* Command examples fetcher.
|
|
335
|
+
* @param ctx A {@link CommandContext | command context}
|
|
336
|
+
* @returns A fetched command examples.
|
|
337
|
+
*/
|
|
338
|
+
type CommandExamplesFetcher<A extends Args = Args, V = ArgValues<A>> = (ctx: Readonly<CommandContext<A, V>>) => Promise<string>;
|
|
339
|
+
/**
|
|
340
|
+
* Command resource fetcher.
|
|
341
|
+
* @param ctx A {@link CommandContext | command context}
|
|
342
|
+
* @returns A fetched {@link CommandResource | command resource}.
|
|
343
|
+
*/
|
|
344
|
+
type CommandResourceFetcher<A extends Args = Args, V = ArgValues<A>> = (ctx: Readonly<CommandContext<A, V>>) => Promise<CommandResource<A>>;
|
|
345
|
+
/**
|
|
346
|
+
* Translation adapter factory.
|
|
347
|
+
*/
|
|
348
|
+
type TranslationAdapterFactory = (options: TranslationAdapterFactoryOptions) => TranslationAdapter;
|
|
349
|
+
/**
|
|
350
|
+
* Translation adapter factory options.
|
|
351
|
+
*/
|
|
347
352
|
interface TranslationAdapterFactoryOptions {
|
|
348
353
|
/**
|
|
349
354
|
* A locale.
|
|
@@ -353,12 +358,12 @@ interface TranslationAdapterFactoryOptions {
|
|
|
353
358
|
* A fallback locale.
|
|
354
359
|
*/
|
|
355
360
|
fallbackLocale: string;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Translation adapter.
|
|
364
|
+
* This adapter is used to custom message formatter like {@link https://github.com/intlify/vue-i18n/blob/master/spec/syntax.ebnf | Intlify message format}, {@link https://github.com/tc39/proposal-intl-messageformat | `Intl.MessageFormat` (MF2)}, and etc.
|
|
365
|
+
* This adapter will support localization with your preferred message format.
|
|
366
|
+
*/
|
|
362
367
|
interface TranslationAdapter<MessageResource = string> {
|
|
363
368
|
/**
|
|
364
369
|
* Get a resource of locale.
|
|
@@ -387,29 +392,29 @@ interface TranslationAdapter<MessageResource = string> {
|
|
|
387
392
|
* @returns A translated message, if message is not translated, return `undefined`.
|
|
388
393
|
*/
|
|
389
394
|
translate(locale: string, key: string, values?: Record<string, unknown>): string | undefined;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
type CommandRunner<
|
|
396
|
-
type CommandLoader<
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
type LazyCommand<
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Command runner.
|
|
398
|
+
* @param ctx A {@link CommandContext | command context}
|
|
399
|
+
*/
|
|
400
|
+
type CommandRunner<A extends Args = Args> = (ctx: Readonly<CommandContext<A>>) => Awaitable<void>;
|
|
401
|
+
type CommandLoader<A extends Args = Args> = () => Awaitable<Command<A> | CommandRunner<A>>;
|
|
402
|
+
/**
|
|
403
|
+
* Lazy command interface.
|
|
404
|
+
* Lazy command that's not loaded until it is executed.
|
|
405
|
+
*/
|
|
406
|
+
type LazyCommand<A extends Args = Args> = {
|
|
402
407
|
/**
|
|
403
408
|
* Command load function
|
|
404
409
|
*/
|
|
405
|
-
(): Awaitable<Command<
|
|
410
|
+
(): Awaitable<Command<A> | CommandRunner<A>>;
|
|
406
411
|
/**
|
|
407
412
|
* Command name
|
|
408
413
|
*/
|
|
409
414
|
commandName?: string;
|
|
410
|
-
} & Omit<Command<
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
type Commandable<
|
|
415
|
-
export { Command,
|
|
415
|
+
} & Omit<Command<A>, 'run' | 'name'>;
|
|
416
|
+
/**
|
|
417
|
+
* Define a command type.
|
|
418
|
+
*/
|
|
419
|
+
type Commandable<A extends Args> = Command<A> | LazyCommand<A>; //#endregion
|
|
420
|
+
export { Command, CommandArgKeys, CommandBuiltinArgsKeys, CommandBuiltinKeys, CommandBuiltinResourceKeys, CommandContext, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandOptions, CommandResource, CommandResourceFetcher, CommandRunner, Commandable, DEFAULT_LOCALE, GenerateNamespacedKey, KeyOfArgs, LazyCommand, RemovedIndex, TranslationAdapter, TranslationAdapterFactory, TranslationAdapterFactoryOptions };
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
const DEFAULT_LOCALE = "en-US";
|
|
6
6
|
const BUILT_IN_PREFIX = "_";
|
|
7
|
-
const
|
|
7
|
+
const ARG_PREFIX = "arg";
|
|
8
8
|
const BUILT_IN_KEY_SEPARATOR = ":";
|
|
9
9
|
const NOOP = () => {};
|
|
10
|
-
const
|
|
10
|
+
const COMMON_ARGS = {
|
|
11
11
|
help: {
|
|
12
12
|
type: "boolean",
|
|
13
13
|
short: "h",
|
|
@@ -44,7 +44,7 @@ async function resolveLazyCommand(cmd, name, needRunResolving = false) {
|
|
|
44
44
|
command = Object.assign(create(), {
|
|
45
45
|
name: cmd.commandName,
|
|
46
46
|
description: cmd.description,
|
|
47
|
-
|
|
47
|
+
args: cmd.args,
|
|
48
48
|
examples: cmd.examples,
|
|
49
49
|
resource: cmd.resource
|
|
50
50
|
});
|
|
@@ -56,7 +56,7 @@ async function resolveLazyCommand(cmd, name, needRunResolving = false) {
|
|
|
56
56
|
command.run = loaded.run;
|
|
57
57
|
command.name = loaded.name;
|
|
58
58
|
command.description = loaded.description;
|
|
59
|
-
command.
|
|
59
|
+
command.args = loaded.args;
|
|
60
60
|
command.examples = loaded.examples;
|
|
61
61
|
command.resource = loaded.resource;
|
|
62
62
|
} else throw new TypeError(`Cannot resolve command: ${cmd.name || name}`);
|
|
@@ -68,8 +68,11 @@ async function resolveLazyCommand(cmd, name, needRunResolving = false) {
|
|
|
68
68
|
function resolveBuiltInKey(key) {
|
|
69
69
|
return `${BUILT_IN_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
return `${
|
|
71
|
+
function resolveArgKey(key) {
|
|
72
|
+
return `${ARG_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`;
|
|
73
|
+
}
|
|
74
|
+
async function resolveExamples(ctx, examples) {
|
|
75
|
+
return typeof examples === "string" ? examples : typeof examples === "function" ? await examples(ctx) : "";
|
|
73
76
|
}
|
|
74
77
|
function mapResourceWithBuiltinKey(resource) {
|
|
75
78
|
return Object.entries(resource).reduce((acc, [key, value]) => {
|
|
@@ -93,4 +96,4 @@ function deepFreeze(obj) {
|
|
|
93
96
|
}
|
|
94
97
|
|
|
95
98
|
//#endregion
|
|
96
|
-
export { BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT,
|
|
99
|
+
export { BUILT_IN_PREFIX, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, DEFAULT_LOCALE as DEFAULT_LOCALE$1, NOOP, create, deepFreeze, log, mapResourceWithBuiltinKey, resolveArgKey, resolveBuiltInKey, resolveExamples, resolveLazyCommand };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gunshi",
|
|
3
3
|
"description": "Modern javascript command-line library",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.20.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"node": ">= 20"
|
|
31
31
|
},
|
|
32
32
|
"type": "module",
|
|
33
|
+
"sideEffects": false,
|
|
33
34
|
"files": [
|
|
34
35
|
"lib"
|
|
35
36
|
],
|
|
@@ -77,7 +78,7 @@
|
|
|
77
78
|
}
|
|
78
79
|
},
|
|
79
80
|
"dependencies": {
|
|
80
|
-
"args-tokens": "^0.
|
|
81
|
+
"args-tokens": "^0.17.1"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
83
84
|
"@eslint/markdown": "^6.4.0",
|
|
@@ -85,10 +86,10 @@
|
|
|
85
86
|
"@kazupon/eslint-config": "^0.29.0",
|
|
86
87
|
"@kazupon/prettier-config": "^0.1.1",
|
|
87
88
|
"@types/node": "^22.15.3",
|
|
88
|
-
"@vitest/eslint-plugin": "^1.1.
|
|
89
|
+
"@vitest/eslint-plugin": "^1.1.44",
|
|
89
90
|
"bumpp": "^10.1.0",
|
|
90
|
-
"deno": "^2.
|
|
91
|
-
"eslint": "^9.
|
|
91
|
+
"deno": "^2.3.1",
|
|
92
|
+
"eslint": "^9.26.0",
|
|
92
93
|
"eslint-config-prettier": "^10.1.2",
|
|
93
94
|
"eslint-import-resolver-typescript": "^4.3.4",
|
|
94
95
|
"eslint-plugin-import": "^2.31.0",
|
|
@@ -98,27 +99,29 @@
|
|
|
98
99
|
"eslint-plugin-regexp": "^2.7.0",
|
|
99
100
|
"eslint-plugin-unicorn": "^58.0.0",
|
|
100
101
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
101
|
-
"eslint-plugin-vue": "^10.0
|
|
102
|
+
"eslint-plugin-vue": "^10.1.0",
|
|
102
103
|
"eslint-plugin-vue-composable": "^1.0.0",
|
|
103
104
|
"eslint-plugin-yml": "^1.18.0",
|
|
104
105
|
"gh-changelogen": "^0.2.8",
|
|
106
|
+
"gunshi019": "npm:gunshi@0.19.0",
|
|
105
107
|
"jsr": "^0.13.4",
|
|
106
108
|
"jsr-exports-lint": "^0.2.0",
|
|
107
|
-
"knip": "^5.
|
|
109
|
+
"knip": "^5.53.0",
|
|
108
110
|
"lint-staged": "^15.5.1",
|
|
109
111
|
"messageformat": "4.0.0-10",
|
|
112
|
+
"mitata": "^1.0.34",
|
|
110
113
|
"pkg-pr-new": "^0.0.43",
|
|
111
114
|
"prettier": "^3.5.3",
|
|
112
115
|
"publint": "^0.3.12",
|
|
113
|
-
"tsdown": "^0.10.
|
|
114
|
-
"typedoc": "^0.28.
|
|
116
|
+
"tsdown": "^0.10.2",
|
|
117
|
+
"typedoc": "^0.28.4",
|
|
115
118
|
"typedoc-plugin-markdown": "^4.6.3",
|
|
116
119
|
"typedoc-vitepress-theme": "^1.1.2",
|
|
117
120
|
"typescript": "^5.8.3",
|
|
118
121
|
"typescript-eslint": "^8.31.1",
|
|
119
122
|
"vitepress": "^1.6.3",
|
|
120
123
|
"vitepress-plugin-group-icons": "^1.5.2",
|
|
121
|
-
"vitepress-plugin-llms": "^1.1.
|
|
124
|
+
"vitepress-plugin-llms": "^1.1.3",
|
|
122
125
|
"vitest": "^3.1.2",
|
|
123
126
|
"vue": "^3.5.13"
|
|
124
127
|
},
|
|
@@ -137,6 +140,8 @@
|
|
|
137
140
|
]
|
|
138
141
|
},
|
|
139
142
|
"scripts": {
|
|
143
|
+
"bench:mitata": "node --expose-gc bench/mitata.js",
|
|
144
|
+
"bench:vitest": "vitest bench --run",
|
|
140
145
|
"build": "tsdown",
|
|
141
146
|
"changelog": "gh-changelogen --repo=kazupon/gunshi",
|
|
142
147
|
"clean": "git clean -df",
|
|
@@ -144,7 +149,7 @@
|
|
|
144
149
|
"dev:eslint": "pnpx @eslint/config-inspector --config eslint.config.ts",
|
|
145
150
|
"dev:typedoc": "typedoc --watch --preserveWatchOutput",
|
|
146
151
|
"docs:build": "pnpm run docs:build:typedoc && pnpm docs:build:vitepress",
|
|
147
|
-
"docs:build:typedoc": "typedoc",
|
|
152
|
+
"docs:build:typedoc": "typedoc --excludeInternal",
|
|
148
153
|
"docs:build:vitepress": "vitepress build docs",
|
|
149
154
|
"docs:dev": "pnpm run docs:build:typedoc && pnpm docs:dev:vitepress",
|
|
150
155
|
"docs:dev:vitepress": "vitepress dev docs",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Command, CommandLoader, LazyCommand } from "./types.d-BqXvgR9J.js";
|
|
2
|
-
import { ArgOptionSchema, ArgOptions, ArgOptions as ArgOptions$1, ArgValues as ArgValues$1 } from "args-tokens";
|
|
3
|
-
|
|
4
|
-
//#region src/definition.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Define a {@link Command | command} with type inference
|
|
7
|
-
* @param definition A {@link Command | command} definition
|
|
8
|
-
* @returns A {@link Command | command} definition with type inference
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
declare function define<Options extends ArgOptions = ArgOptions>(definition: Command<Options>): Command<Options>; /**
|
|
12
|
-
* Define a {@link LazyCommand | lazy command} with command loader, which is attached with command definition as usage metadata.
|
|
13
|
-
* @param loader A {@link CommandLoader | command loader}
|
|
14
|
-
* @param definition A {@link Command | command} definition
|
|
15
|
-
* @returns A {@link LazyCommand | lazy command} loader
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
declare function lazy<Options extends ArgOptions = ArgOptions>(loader: CommandLoader<Options>, definition?: Command<Options>): LazyCommand<Options>;
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { ArgOptionSchema, ArgOptions$1 as ArgOptions, ArgValues$1 as ArgValues, define as define$1, lazy as lazy$1 };
|