@gunshi/bone 1.0.0-rc.6 → 1.0.0-rc.7
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/index.d.ts +190 -32
- package/lib/index.js +446 -244
- package/package.json +32 -33
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region ../gunshi/src/constants.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* The key of the mark on the `json` argument of `jsonArgs`. A string key, not a symbol: `gunshi` and the other
|
|
4
3
|
* packages bundle their own copies of the types, and each copy of a `unique symbol` is a different type.
|
|
@@ -6,8 +5,6 @@
|
|
|
6
5
|
* @internal
|
|
7
6
|
*/
|
|
8
7
|
declare const JSON_ARG = "~gunshi.json-arg";
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region ../../node_modules/.pnpm/args-tokens@1.0.2/node_modules/args-tokens/lib/parser-DvPxBZG9.d.ts
|
|
11
8
|
/**
|
|
12
9
|
* Entry point of argument parser.
|
|
13
10
|
*
|
|
@@ -63,13 +60,11 @@ interface ArgToken {
|
|
|
63
60
|
*/
|
|
64
61
|
inlineValue?: boolean | undefined;
|
|
65
62
|
}
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region ../../node_modules/.pnpm/args-tokens@1.0.2/node_modules/args-tokens/lib/resolver.d.ts
|
|
68
63
|
/**
|
|
69
64
|
* An argument schema definition for command-line argument parsing.
|
|
70
65
|
*
|
|
71
66
|
* This schema is similar to the schema of Node.js `util.parseArgs` but with extended features:
|
|
72
|
-
* - Additional `required`, `description`, and `
|
|
67
|
+
* - Additional `required`, `description`, `hidden`, and `deprecated` properties
|
|
73
68
|
* - Extended `type` support: 'string', 'boolean', 'number', 'enum', 'positional', 'custom'
|
|
74
69
|
* - Simplified `default` property (single type, not union types)
|
|
75
70
|
*
|
|
@@ -199,6 +194,32 @@ interface ArgSchema {
|
|
|
199
194
|
* ```
|
|
200
195
|
*/
|
|
201
196
|
hidden?: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Mark the argument as deprecated: `true`, or a text that tells what to use instead, such as
|
|
199
|
+
* `'Use --output.'`.
|
|
200
|
+
*
|
|
201
|
+
* Like {@link ArgSchema.hidden}, this is metadata for the tools that read the schema, such as a CLI
|
|
202
|
+
* framework that warns when a deprecated argument is given and leaves it out of the help. It does
|
|
203
|
+
* not affect parsing, validation, required checks, defaults, conflicts, or resolved values: a
|
|
204
|
+
* deprecated argument still works. `false`, like leaving it out, means that the argument is not
|
|
205
|
+
* deprecated.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* The old name of an option, kept while the scripts that use it move to the new one:
|
|
209
|
+
* ```ts
|
|
210
|
+
* {
|
|
211
|
+
* output: {
|
|
212
|
+
* type: 'string',
|
|
213
|
+
* description: 'Output format'
|
|
214
|
+
* },
|
|
215
|
+
* format: {
|
|
216
|
+
* type: 'string',
|
|
217
|
+
* deprecated: 'Use --output.'
|
|
218
|
+
* }
|
|
219
|
+
* }
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
deprecated?: boolean | string;
|
|
202
223
|
/**
|
|
203
224
|
* Marks the argument as required.
|
|
204
225
|
*
|
|
@@ -704,8 +725,6 @@ type MayBeUnrequired<A extends ArgSchema> = false extends A['required'] ? [A] ex
|
|
|
704
725
|
* @typeParam A - {@link Args | Arguments}, which is an object that defines the command line arguments.
|
|
705
726
|
*/
|
|
706
727
|
type ArgExplicitlyProvided<A extends Args> = { [K in keyof A]: boolean; };
|
|
707
|
-
//#endregion
|
|
708
|
-
//#region ../gunshi/src/plugin/context.d.ts
|
|
709
728
|
/**
|
|
710
729
|
* Gunshi plugin context interface.
|
|
711
730
|
*
|
|
@@ -782,8 +801,6 @@ interface PluginContext<G extends GunshiParamsConstraint = DefaultGunshiParams>
|
|
|
782
801
|
*/
|
|
783
802
|
decorateCommand<L extends Record<string, unknown> = DefaultGunshiParams['extensions']>(decorator: (baseRunner: (ctx: Readonly<CommandContext<MergeGunshiExtensions<G, L>>>) => Awaitable<void | string | JsonResult>) => (ctx: Readonly<CommandContext<MergeGunshiExtensions<G, L>>>) => Awaitable<void | string | JsonResult>): void;
|
|
784
803
|
}
|
|
785
|
-
//#endregion
|
|
786
|
-
//#region ../gunshi/src/plugin/core.d.ts
|
|
787
804
|
/**
|
|
788
805
|
* Plugin dependency definition
|
|
789
806
|
*
|
|
@@ -824,8 +841,6 @@ type Plugin<E extends GunshiParams['extensions'] = DefaultGunshiParams['extensio
|
|
|
824
841
|
dependencies?: (PluginDependency | string)[];
|
|
825
842
|
extension?: CommandContextExtension<E>;
|
|
826
843
|
};
|
|
827
|
-
//#endregion
|
|
828
|
-
//#region ../gunshi/src/types.d.ts
|
|
829
844
|
/**
|
|
830
845
|
* Awaitable type.
|
|
831
846
|
*
|
|
@@ -1034,6 +1049,28 @@ interface CommandEnvironment<G extends GunshiParamsConstraint = DefaultGunshiPar
|
|
|
1034
1049
|
* @see {@linkcode CliOptions.strict}
|
|
1035
1050
|
*/
|
|
1036
1051
|
strict: boolean;
|
|
1052
|
+
/**
|
|
1053
|
+
* Whether to treat the positional arguments that the command does not take as argument validation errors.
|
|
1054
|
+
*
|
|
1055
|
+
* @default false
|
|
1056
|
+
* @see {@linkcode CliOptions.strictPositionals}
|
|
1057
|
+
*/
|
|
1058
|
+
strictPositionals: boolean;
|
|
1059
|
+
/**
|
|
1060
|
+
* Whether to follow the validation errors with the command that shows the help.
|
|
1061
|
+
*
|
|
1062
|
+
* @default true
|
|
1063
|
+
* @see {@linkcode CliOptions.helpHint}
|
|
1064
|
+
*/
|
|
1065
|
+
helpHint: boolean;
|
|
1066
|
+
/**
|
|
1067
|
+
* The exit code of the validation errors. A command can give it to a `CommandError`, to end an
|
|
1068
|
+
* argument error that it finds itself with the same exit code.
|
|
1069
|
+
*
|
|
1070
|
+
* @default 1
|
|
1071
|
+
* @see {@linkcode CliOptions.validationErrorExitCode}
|
|
1072
|
+
*/
|
|
1073
|
+
validationErrorExitCode: number;
|
|
1037
1074
|
/**
|
|
1038
1075
|
* Sub commands.
|
|
1039
1076
|
*
|
|
@@ -1123,9 +1160,11 @@ interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams> {
|
|
|
1123
1160
|
* Sub commands.
|
|
1124
1161
|
*
|
|
1125
1162
|
* An object or a Map keyed by the sub-command names, or an array of commands, which are keyed by their names.
|
|
1163
|
+
* A value of the object or the Map may also be a loader, a function that returns the command or its runner,
|
|
1164
|
+
* which runs as a lazy command named after its key.
|
|
1126
1165
|
* When this is not given, the {@linkcode Command.subCommands} of the entry command are the sub-commands.
|
|
1127
1166
|
*/
|
|
1128
|
-
subCommands?: Record<string, SubCommandable> | Map<string, SubCommandable> | readonly SubCommandable[];
|
|
1167
|
+
subCommands?: Record<string, SubCommandable | SubCommandLoader> | Map<string, SubCommandable | SubCommandLoader> | readonly SubCommandable[];
|
|
1129
1168
|
/**
|
|
1130
1169
|
* Left margin of the command output.
|
|
1131
1170
|
*/
|
|
@@ -1164,6 +1203,10 @@ interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams> {
|
|
|
1164
1203
|
* arguments or installed global options are reported as validation errors
|
|
1165
1204
|
* before the command runner is executed.
|
|
1166
1205
|
*
|
|
1206
|
+
* With the global options plugin, `--help` and `--version` are still answered: given with them, an
|
|
1207
|
+
* unknown option is not reported, as the other argument validation errors are not. An unknown command
|
|
1208
|
+
* is still reported.
|
|
1209
|
+
*
|
|
1167
1210
|
* `--json` is not reported, since gunshi knows what it means: given to a command that does not
|
|
1168
1211
|
* spread `jsonArgs`, the global options plugin reports `json_not_supported` for it instead, with or
|
|
1169
1212
|
* without `strict`. `--json=false` asks for no JSON, and is reported.
|
|
@@ -1171,6 +1214,23 @@ interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams> {
|
|
|
1171
1214
|
* @default false
|
|
1172
1215
|
*/
|
|
1173
1216
|
strict?: boolean;
|
|
1217
|
+
/**
|
|
1218
|
+
* Whether to treat the positional arguments that the command does not take as argument validation
|
|
1219
|
+
* errors, as `strict` does for the options.
|
|
1220
|
+
*
|
|
1221
|
+
* When enabled, the positional arguments after the command path that the positional arguments of the
|
|
1222
|
+
* resolved command do not take are reported as validation errors before the command runner is
|
|
1223
|
+
* executed. A command takes as many as it declares, an optional one included, and any number with a
|
|
1224
|
+
* positional argument with `multiple: true`. The arguments after `--` are not positional arguments:
|
|
1225
|
+
* they stay in `rest`.
|
|
1226
|
+
*
|
|
1227
|
+
* With the global options plugin, `--help` and `--version` are still answered, as they are with the
|
|
1228
|
+
* other argument validation errors. After a command with sub-commands, a word that is not one of them
|
|
1229
|
+
* is reported as an unknown command instead.
|
|
1230
|
+
*
|
|
1231
|
+
* @default false
|
|
1232
|
+
*/
|
|
1233
|
+
strictPositionals?: boolean;
|
|
1174
1234
|
/**
|
|
1175
1235
|
* Render function the command usage.
|
|
1176
1236
|
*/
|
|
@@ -1183,7 +1243,10 @@ interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams> {
|
|
|
1183
1243
|
* Render function the validation errors.
|
|
1184
1244
|
*
|
|
1185
1245
|
* With the global options plugin, the rendered message is printed to stderr, the exit code is set
|
|
1186
|
-
* to
|
|
1246
|
+
* to {@linkcode CliOptions.validationErrorExitCode}, `1` by default,
|
|
1247
|
+
* {@linkcode CliOptions.onErrorCommand} is called, and `cli()` resolves with `undefined`.
|
|
1248
|
+
* The message is followed by the command that shows the help, unless {@linkcode CliOptions.helpHint}
|
|
1249
|
+
* is `false`.
|
|
1187
1250
|
* Set it to `null` to report the validation errors yourself: nothing is printed, and `cli()` rejects
|
|
1188
1251
|
* with the `AggregateError`. A renderer that returns an empty message, and
|
|
1189
1252
|
* {@linkcode CliOptions.usageSilent}, also leave them to the caller.
|
|
@@ -1192,9 +1255,48 @@ interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams> {
|
|
|
1192
1255
|
* the renderer. `null` and {@linkcode CliOptions.usageSilent} still leave them to the caller.
|
|
1193
1256
|
*/
|
|
1194
1257
|
renderValidationErrors?: ((ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>) | null;
|
|
1258
|
+
/**
|
|
1259
|
+
* Whether to follow the validation errors with the command that shows the help of the nearest
|
|
1260
|
+
* command: the command itself for an argument error, and the parent of an unknown command, such as
|
|
1261
|
+
* `my-app deploy --help`. With the global options plugin, it is printed to stderr after the errors,
|
|
1262
|
+
* after an empty line and a heading. It is the command that `next` of the JSON error has with
|
|
1263
|
+
* `--json`.
|
|
1264
|
+
*
|
|
1265
|
+
* Set it to `false` to leave the command out, such as when your renderer of the validation errors
|
|
1266
|
+
* points to the help in its own way. It changes the output for people only: `next` of the JSON error
|
|
1267
|
+
* stays. The command is left out for a command whose `--help` does not show the help, too: one that
|
|
1268
|
+
* declares a `help` argument of its own, or with `renderUsage: null`.
|
|
1269
|
+
*
|
|
1270
|
+
* @default true
|
|
1271
|
+
*/
|
|
1272
|
+
helpHint?: boolean;
|
|
1273
|
+
/**
|
|
1274
|
+
* The exit code of the validation errors, such as `2`, the exit code of a usage error in many
|
|
1275
|
+
* command-line tools. They are the errors of the arguments: a missing or invalid argument, an unknown
|
|
1276
|
+
* command or a command line that cannot be resolved, an unknown option of `strict`, a positional
|
|
1277
|
+
* argument that the command does not take of `strictPositionals`, and `--json` given to a command
|
|
1278
|
+
* that does not spread `jsonArgs`. With the global options plugin, the exit code is set to it when
|
|
1279
|
+
* the errors are printed, as text or as JSON, before {@linkcode CliOptions.onErrorCommand} is called,
|
|
1280
|
+
* which can still change it.
|
|
1281
|
+
*
|
|
1282
|
+
* It is an integer from `1` to `255`, as the `exitCode` of a `CommandError` is, and any other value is
|
|
1283
|
+
* replaced with `1`. It does not change the exit code of a `CommandError`, nor of any other error that a
|
|
1284
|
+
* command throws. With `renderValidationErrors: null`, a renderer that returns an empty message, or
|
|
1285
|
+
* {@linkcode CliOptions.usageSilent}, nothing is printed, and the exit code is left alone.
|
|
1286
|
+
*
|
|
1287
|
+
* @default 1
|
|
1288
|
+
*/
|
|
1289
|
+
validationErrorExitCode?: number;
|
|
1195
1290
|
/**
|
|
1196
1291
|
* Whether to fallback to entry command when the sub-command is not found.
|
|
1197
1292
|
*
|
|
1293
|
+
* When it is not set, it is `true` for a CLI that declares no sub-commands and to which a plugin adds
|
|
1294
|
+
* commands, such as the `complete` command of `@gunshi/plugin-completion`, so that the positional
|
|
1295
|
+
* arguments of the entry command are not taken for command names. This is so when the entry command
|
|
1296
|
+
* has something to run: a command object with `run`, a lazy command, whose loader gives the runner,
|
|
1297
|
+
* or a runner given to `cli()`. For a command object without `run`, it stays `false`: the commands of
|
|
1298
|
+
* the plugins are then the commands of the CLI, and an argument that is not one of them is reported.
|
|
1299
|
+
*
|
|
1198
1300
|
* @default false
|
|
1199
1301
|
* @since v0.27.0
|
|
1200
1302
|
*/
|
|
@@ -1225,9 +1327,9 @@ interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams> {
|
|
|
1225
1327
|
* Hook that runs when a command throws an error, or when the arguments fail validation
|
|
1226
1328
|
*
|
|
1227
1329
|
* For the validation errors and a `CommandError` that the global options plugin has printed, the
|
|
1228
|
-
* exit code is already set when the hook runs (
|
|
1229
|
-
* a `CommandError`), so the hook can set another one, and
|
|
1230
|
-
* error rejects `cli()` after the hook.
|
|
1330
|
+
* exit code is already set when the hook runs ({@linkcode CliOptions.validationErrorExitCode} for the
|
|
1331
|
+
* validation errors, and the `exitCode` of a `CommandError`), so the hook can set another one, and
|
|
1332
|
+
* `cli()` resolves after it. Any other error rejects `cli()` after the hook.
|
|
1231
1333
|
*
|
|
1232
1334
|
* @param ctx - The command context
|
|
1233
1335
|
* @param error - The error thrown during execution, or the `AggregateError` of the validation errors
|
|
@@ -1285,8 +1387,9 @@ interface CommandContext<G extends GunshiParamsConstraint = DefaultGunshiParams>
|
|
|
1285
1387
|
*/
|
|
1286
1388
|
values: ArgValues<ExtractArgs<G>>;
|
|
1287
1389
|
/**
|
|
1288
|
-
*
|
|
1289
|
-
*
|
|
1390
|
+
* The positional arguments of the command line, the names of the command path first: `app deploy web`
|
|
1391
|
+
* gives `['deploy', 'web']`. The positional arguments of the command itself are
|
|
1392
|
+
* `positionals.slice(commandPath.length)`, and the ones that it declares are in `values` too.
|
|
1290
1393
|
*/
|
|
1291
1394
|
positionals: string[];
|
|
1292
1395
|
/**
|
|
@@ -1304,6 +1407,9 @@ interface CommandContext<G extends GunshiParamsConstraint = DefaultGunshiParams>
|
|
|
1304
1407
|
tokens: ArgToken[];
|
|
1305
1408
|
/**
|
|
1306
1409
|
* Whether the currently executing command has been executed with the sub-command name omitted.
|
|
1410
|
+
*
|
|
1411
|
+
* A command that has sub-commands and no {@linkcode Command.run | run} prints its usage then, with
|
|
1412
|
+
* the global options plugin, as `--help` does.
|
|
1307
1413
|
*/
|
|
1308
1414
|
omitted: boolean;
|
|
1309
1415
|
/**
|
|
@@ -1437,6 +1543,14 @@ interface Command<G extends GunshiParamsConstraint = DefaultGunshiParams> {
|
|
|
1437
1543
|
examples?: string | CommandExamplesFetcher<G>;
|
|
1438
1544
|
/**
|
|
1439
1545
|
* Command runner. it's the command to be executed
|
|
1546
|
+
*
|
|
1547
|
+
* A command that has sub-commands needs no runner: run without a sub-command, it prints its usage,
|
|
1548
|
+
* with the global options plugin, as `--help` does. A command with a runner runs it then, with
|
|
1549
|
+
* {@linkcode CommandContext.omitted | omitted} set to `true`.
|
|
1550
|
+
*
|
|
1551
|
+
* A command without sub-commands needs a runner. Without one, it throws a `TypeError` when it runs
|
|
1552
|
+
* (`'run' is required in command: <name>`), and `--help` still prints its usage. So does a lazy command
|
|
1553
|
+
* whose loader returns a command without a runner.
|
|
1440
1554
|
*/
|
|
1441
1555
|
run?: CommandRunner<G>;
|
|
1442
1556
|
/**
|
|
@@ -1452,6 +1566,34 @@ interface Command<G extends GunshiParamsConstraint = DefaultGunshiParams> {
|
|
|
1452
1566
|
* @since v0.27.0
|
|
1453
1567
|
*/
|
|
1454
1568
|
internal?: boolean;
|
|
1569
|
+
/**
|
|
1570
|
+
* Other names of the command, such as `['ls']` for `list`.
|
|
1571
|
+
*
|
|
1572
|
+
* The command runs with any of them, as with its name, and `ctx.name` and `ctx.commandPath` have its name:
|
|
1573
|
+
* the help, the hints and the help as JSON tell the name of the command. An alias is accepted but not taught:
|
|
1574
|
+
* the help does not list it, and the `Did you mean` hint for an unknown command and shell completion do not
|
|
1575
|
+
* offer it.
|
|
1576
|
+
*
|
|
1577
|
+
* A sub-command whose name is the alias wins over the alias, so an alias never hides a command. Two commands
|
|
1578
|
+
* at the same level with the same alias are a mistake: using the alias throws a `TypeError`. A lazy command
|
|
1579
|
+
* takes its aliases from the definition given to `lazy`, as it is found before it is loaded.
|
|
1580
|
+
*/
|
|
1581
|
+
aliases?: readonly string[];
|
|
1582
|
+
/**
|
|
1583
|
+
* Whether the command is deprecated: `true`, or the text that tells what to use instead, such as `'Use deploy.'`.
|
|
1584
|
+
*
|
|
1585
|
+
* A deprecated command still runs. With the global options plugin, it prints a warning to stderr when it runs,
|
|
1586
|
+
* once: `push is deprecated. Use deploy.`, and not when the command is asked for JSON with `--json`. A command
|
|
1587
|
+
* under a deprecated group, such as the old name of a renamed group, warns of the group too. Its help says that
|
|
1588
|
+
* it is deprecated, after its description. As an internal command, it is left out of the help, the
|
|
1589
|
+
* `Did you mean` hint for an unknown command, shell completion and the help as JSON, so that they teach what to
|
|
1590
|
+
* use instead.
|
|
1591
|
+
*
|
|
1592
|
+
* To rename a command, keep the old name as a deprecated command that runs as the new one, such as
|
|
1593
|
+
* `push: define({ ...deploy, name: 'push', aliases: [], deprecated: 'Use deploy.' })`, where `aliases: []` takes
|
|
1594
|
+
* the aliases that the spread copies off the old name. It has no effect on the entry command.
|
|
1595
|
+
*/
|
|
1596
|
+
deprecated?: boolean | string;
|
|
1455
1597
|
/**
|
|
1456
1598
|
* Whether this command is an entry command.
|
|
1457
1599
|
*
|
|
@@ -1469,14 +1611,15 @@ interface Command<G extends GunshiParamsConstraint = DefaultGunshiParams> {
|
|
|
1469
1611
|
* Nested sub-commands for this command.
|
|
1470
1612
|
*
|
|
1471
1613
|
* Allows building command trees like `git remote add`.
|
|
1472
|
-
* Each key is the sub-command name, and the value is a command
|
|
1614
|
+
* Each key is the sub-command name, and the value is a command, a lazy command, or a loader, a function that
|
|
1615
|
+
* returns the command or its runner, which runs as a lazy command named after its key.
|
|
1473
1616
|
* An array of commands is keyed by the names of the commands.
|
|
1474
1617
|
*
|
|
1475
1618
|
* On the entry command, these are the top-level sub-commands when {@linkcode CliOptions.subCommands} is not given.
|
|
1476
1619
|
*
|
|
1477
1620
|
* @since v0.28.0
|
|
1478
1621
|
*/
|
|
1479
|
-
subCommands?: Record<string, SubCommandable> | Map<string, SubCommandable> | readonly SubCommandable[];
|
|
1622
|
+
subCommands?: Record<string, SubCommandable | SubCommandLoader> | Map<string, SubCommandable | SubCommandLoader> | readonly SubCommandable[];
|
|
1480
1623
|
}
|
|
1481
1624
|
/**
|
|
1482
1625
|
* Lazy command interface.
|
|
@@ -1504,6 +1647,13 @@ type LazyCommand<G extends GunshiParamsConstraint = DefaultGunshiParams, D exten
|
|
|
1504
1647
|
* @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command.
|
|
1505
1648
|
*/
|
|
1506
1649
|
type Commandable<G extends GunshiParamsConstraint = DefaultGunshiParams> = Command<G> | LazyCommand<G, {}>;
|
|
1650
|
+
/**
|
|
1651
|
+
* A function given as a sub-command, which the CLI loads as a lazy command named after its key:
|
|
1652
|
+
* it returns the command, or its runner
|
|
1653
|
+
*
|
|
1654
|
+
* @internal
|
|
1655
|
+
*/
|
|
1656
|
+
type SubCommandLoader = () => Awaitable<SubCommandable | ((...args: any[]) => any)>;
|
|
1507
1657
|
/**
|
|
1508
1658
|
* Sub-command entry type for use in subCommands.
|
|
1509
1659
|
*
|
|
@@ -1541,6 +1691,14 @@ interface SubCommandable {
|
|
|
1541
1691
|
* see {@link Command.internal}
|
|
1542
1692
|
*/
|
|
1543
1693
|
internal?: boolean;
|
|
1694
|
+
/**
|
|
1695
|
+
* see {@link Command.aliases}
|
|
1696
|
+
*/
|
|
1697
|
+
aliases?: readonly string[];
|
|
1698
|
+
/**
|
|
1699
|
+
* see {@link Command.deprecated}
|
|
1700
|
+
*/
|
|
1701
|
+
deprecated?: boolean | string;
|
|
1544
1702
|
/**
|
|
1545
1703
|
* see {@link Command.entry}
|
|
1546
1704
|
*/
|
|
@@ -1560,10 +1718,6 @@ interface SubCommandable {
|
|
|
1560
1718
|
* @since v0.28.0
|
|
1561
1719
|
*/
|
|
1562
1720
|
subCommands?: Record<string, any> | Map<string, any> | readonly any[];
|
|
1563
|
-
/**
|
|
1564
|
-
* Index signature to allow additional properties
|
|
1565
|
-
*/
|
|
1566
|
-
[key: string]: any;
|
|
1567
1721
|
}
|
|
1568
1722
|
/**
|
|
1569
1723
|
* Command examples fetcher.
|
|
@@ -1620,6 +1774,13 @@ type IsAnyArgs<A> = 0 extends 1 & A ? true : false;
|
|
|
1620
1774
|
* A function that returns a command or command runner.
|
|
1621
1775
|
* This is used to lazily load commands.
|
|
1622
1776
|
*
|
|
1777
|
+
* Any other value, such as `null` or `undefined`, fails with `Cannot resolve command: <name>`. To tell
|
|
1778
|
+
* what went wrong, such as a module that is not found, throw an error instead, such as a
|
|
1779
|
+
* `CommandError`. An error of the loading is thrown where the command would run, as an error of
|
|
1780
|
+
* `run` is: a `CommandError` prints its message with its exit code, `--json` prints the failure as JSON,
|
|
1781
|
+
* and `onErrorCommand` sees it. Until then, the definition given to `lazy` stands for the command, so that
|
|
1782
|
+
* `--help` prints its usage.
|
|
1783
|
+
*
|
|
1623
1784
|
* @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command context and command runner.
|
|
1624
1785
|
*
|
|
1625
1786
|
* @returns A command or command runner
|
|
@@ -1671,8 +1832,6 @@ type RendererDecorator<T, G extends GunshiParamsConstraint = DefaultGunshiParams
|
|
|
1671
1832
|
* @since v0.27.0
|
|
1672
1833
|
*/
|
|
1673
1834
|
type ValidationErrorsDecorator<G extends GunshiParamsConstraint = DefaultGunshiParams> = (baseRenderer: (ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>, ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>;
|
|
1674
|
-
//#endregion
|
|
1675
|
-
//#region ../gunshi/src/cli/bone.d.ts
|
|
1676
1835
|
/**
|
|
1677
1836
|
* Run the command, without the built-in plugins: `--help` and `--version` print nothing, unless you add the plugins.
|
|
1678
1837
|
* To have them, use `cli` from `gunshi`.
|
|
@@ -1684,7 +1843,7 @@ type ValidationErrorsDecorator<G extends GunshiParamsConstraint = DefaultGunshiP
|
|
|
1684
1843
|
* @param options - A {@link CliOptions | CLI options}
|
|
1685
1844
|
* @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
|
|
1686
1845
|
*/
|
|
1687
|
-
declare function cli<A extends Args = Args, G extends GunshiParams = {
|
|
1846
|
+
export declare function cli<A extends Args = Args, G extends GunshiParams = {
|
|
1688
1847
|
args: A;
|
|
1689
1848
|
extensions: {};
|
|
1690
1849
|
}>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
|
|
@@ -1699,7 +1858,7 @@ declare function cli<A extends Args = Args, G extends GunshiParams = {
|
|
|
1699
1858
|
* @param options - A {@link CliOptions | CLI options}
|
|
1700
1859
|
* @returns A rendered usage or undefined. if you will use {@link CliOptions.usageSilent} option, it will return rendered usage string.
|
|
1701
1860
|
*/
|
|
1702
|
-
declare function cli<E extends ExtendContext = ExtendContext, G extends GunshiParams = {
|
|
1861
|
+
export declare function cli<E extends ExtendContext = ExtendContext, G extends GunshiParams = {
|
|
1703
1862
|
args: Args;
|
|
1704
1863
|
extensions: E;
|
|
1705
1864
|
}>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
|
|
@@ -1714,6 +1873,5 @@ declare function cli<E extends ExtendContext = ExtendContext, G extends GunshiPa
|
|
|
1714
1873
|
* @param options - A {@link CliOptions | CLI options}
|
|
1715
1874
|
* @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
|
|
1716
1875
|
*/
|
|
1717
|
-
declare function cli<G extends GunshiParams = DefaultGunshiParams>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
|
|
1718
|
-
|
|
1719
|
-
export { type ArgSchema, type ArgToken, type ArgValues, type Args, type Awaitable, type CliOptions, type Command, type CommandCallMode, type CommandContext, type CommandContextCore, type CommandContextExtension, type CommandDecorator, type CommandEnvironment, type CommandExamplesFetcher, type CommandLoader, type CommandRunner, type CommandRunnerResult, type Commandable, type DefaultGunshiParams, type ExtendContext, type ExtractArgExplicitlyProvided, type ExtractArgs, type ExtractExtensions, type GunshiParams, type GunshiParamsConstraint, type HasJsonArgs, type JsonResult, type LazyCommand, type MergeGunshiExtensions, type NormalizeToGunshiParams, type Prettify, type RendererDecorator, type RenderingOptions, type SubCommandable, type ValidationErrorsDecorator, cli };
|
|
1876
|
+
export declare function cli<G extends GunshiParams = DefaultGunshiParams>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
|
|
1877
|
+
export type { ArgSchema, ArgToken, ArgValues, Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, CommandRunnerResult, Commandable, DefaultGunshiParams, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, HasJsonArgs, JsonResult, LazyCommand, MergeGunshiExtensions, NormalizeToGunshiParams, Prettify, RendererDecorator, RenderingOptions, SubCommandable, ValidationErrorsDecorator };
|