@gunshi/plugin 0.27.5 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +36 -7
- package/lib/index.js +2 -1
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.23.
|
|
1
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.23.1/node_modules/args-tokens/lib/parser.d.ts
|
|
2
2
|
//#region src/parser.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Entry point of argument parser.
|
|
@@ -55,9 +55,8 @@ interface ArgToken {
|
|
|
55
55
|
* Parser Options.
|
|
56
56
|
*/
|
|
57
57
|
//#endregion
|
|
58
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.23.
|
|
58
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.23.1/node_modules/args-tokens/lib/resolver.d.ts
|
|
59
59
|
//#region src/resolver.d.ts
|
|
60
|
-
|
|
61
60
|
/**
|
|
62
61
|
* An argument schema definition for command-line argument parsing.
|
|
63
62
|
*
|
|
@@ -504,7 +503,7 @@ type ResolveArgValues<A extends Args, V extends Record<keyof A, unknown>> = { -r
|
|
|
504
503
|
*
|
|
505
504
|
* @internal
|
|
506
505
|
*/
|
|
507
|
-
type FilterArgs<A extends Args, V extends Record<keyof A, unknown>, K
|
|
506
|
+
type FilterArgs<A extends Args, V extends Record<keyof A, unknown>, K extends keyof ArgSchema> = { [Arg in keyof A as A[Arg][K] extends {} ? Arg : never]: V[Arg] };
|
|
508
507
|
/**
|
|
509
508
|
* Filters positional arguments from the argument schema.
|
|
510
509
|
*
|
|
@@ -921,7 +920,7 @@ type ExtendContext = Record<string, unknown>;
|
|
|
921
920
|
*
|
|
922
921
|
* @since v0.27.0
|
|
923
922
|
*/
|
|
924
|
-
interface GunshiParams<P
|
|
923
|
+
interface GunshiParams<P extends {
|
|
925
924
|
args?: Args;
|
|
926
925
|
extensions?: ExtendContext;
|
|
927
926
|
} = {
|
|
@@ -931,13 +930,13 @@ interface GunshiParams<P$1 extends {
|
|
|
931
930
|
/**
|
|
932
931
|
* Command argument definitions.
|
|
933
932
|
*/
|
|
934
|
-
args: P
|
|
933
|
+
args: P extends {
|
|
935
934
|
args: infer A extends Args;
|
|
936
935
|
} ? A : Args;
|
|
937
936
|
/**
|
|
938
937
|
* Command context extensions.
|
|
939
938
|
*/
|
|
940
|
-
extensions: P
|
|
939
|
+
extensions: P extends {
|
|
941
940
|
extensions: infer E extends ExtendContext;
|
|
942
941
|
} ? E : {};
|
|
943
942
|
}
|
|
@@ -1273,6 +1272,15 @@ interface CommandContext<G extends GunshiParamsConstraint = DefaultGunshiParams>
|
|
|
1273
1272
|
* The command call mode is `entry` when the command is executed as an entry command, and `subCommand` when the command is executed as a sub-command.
|
|
1274
1273
|
*/
|
|
1275
1274
|
callMode: CommandCallMode;
|
|
1275
|
+
/**
|
|
1276
|
+
* The path of nested sub-commands that were resolved to reach the current command.
|
|
1277
|
+
*
|
|
1278
|
+
* For example, if the user runs `git remote add`, `commandPath` would be `['remote', 'add']`.
|
|
1279
|
+
* For the entry command, this is an empty array.
|
|
1280
|
+
*
|
|
1281
|
+
* @since v0.28.0
|
|
1282
|
+
*/
|
|
1283
|
+
commandPath: string[];
|
|
1276
1284
|
/**
|
|
1277
1285
|
* Whether to convert the camel-case style argument name to kebab-case.
|
|
1278
1286
|
* This context value is set from {@linkcode Command.toKebab} option.
|
|
@@ -1414,6 +1422,15 @@ interface Command<G extends GunshiParamsConstraint = DefaultGunshiParams> {
|
|
|
1414
1422
|
* @since v0.27.0
|
|
1415
1423
|
*/
|
|
1416
1424
|
rendering?: RenderingOptions<G>;
|
|
1425
|
+
/**
|
|
1426
|
+
* Nested sub-commands for this command.
|
|
1427
|
+
*
|
|
1428
|
+
* Allows building command trees like `git remote add`.
|
|
1429
|
+
* Each key is the sub-command name, and the value is a command or lazy command.
|
|
1430
|
+
*
|
|
1431
|
+
* @since v0.28.0
|
|
1432
|
+
*/
|
|
1433
|
+
subCommands?: Record<string, SubCommandable> | Map<string, SubCommandable>;
|
|
1417
1434
|
}
|
|
1418
1435
|
/**
|
|
1419
1436
|
* Lazy command interface.
|
|
@@ -1484,6 +1501,13 @@ interface SubCommandable {
|
|
|
1484
1501
|
* see {@link LazyCommand.commandName}
|
|
1485
1502
|
*/
|
|
1486
1503
|
commandName?: string;
|
|
1504
|
+
/**
|
|
1505
|
+
* Nested sub-commands for this command.
|
|
1506
|
+
*
|
|
1507
|
+
* @see {@link Command.subCommands}
|
|
1508
|
+
* @since v0.28.0
|
|
1509
|
+
*/
|
|
1510
|
+
subCommands?: Record<string, any> | Map<string, any>;
|
|
1487
1511
|
/**
|
|
1488
1512
|
* Index signature to allow additional properties
|
|
1489
1513
|
*/
|
|
@@ -1605,6 +1629,10 @@ interface CommandContextParams<G extends GunshiParams | {
|
|
|
1605
1629
|
* Command call mode.
|
|
1606
1630
|
*/
|
|
1607
1631
|
callMode?: CommandCallMode;
|
|
1632
|
+
/**
|
|
1633
|
+
* The path of nested sub-commands resolved to reach the current command.
|
|
1634
|
+
*/
|
|
1635
|
+
commandPath?: string[];
|
|
1608
1636
|
/**
|
|
1609
1637
|
* A target command
|
|
1610
1638
|
*/
|
|
@@ -1640,6 +1668,7 @@ declare function createCommandContext<G extends GunshiParamsConstraint = Default
|
|
|
1640
1668
|
extensions,
|
|
1641
1669
|
cliOptions,
|
|
1642
1670
|
callMode,
|
|
1671
|
+
commandPath,
|
|
1643
1672
|
omitted,
|
|
1644
1673
|
validationError
|
|
1645
1674
|
}: CommandContextParams<G, V, C, E>): Promise<{} extends ExtractExtensions$1<E> ? Readonly<CommandContext<G>> : Readonly<CommandContext<GunshiParams<{
|
package/lib/index.js
CHANGED
|
@@ -90,7 +90,7 @@ function deepFreeze(obj, ignores = []) {
|
|
|
90
90
|
* @param param - A {@link CommandContextParams | parameters} to create a command context.
|
|
91
91
|
* @returns A {@link CommandContext | command context}, which is readonly.
|
|
92
92
|
*/
|
|
93
|
-
async function createCommandContext({ args = {}, explicit = {}, values = {}, positionals = [], rest = [], argv = [], tokens = [], command = {}, extensions = {}, cliOptions = {}, callMode = "entry", omitted = false, validationError = void 0 }) {
|
|
93
|
+
async function createCommandContext({ args = {}, explicit = {}, values = {}, positionals = [], rest = [], argv = [], tokens = [], command = {}, extensions = {}, cliOptions = {}, callMode = "entry", commandPath = [], omitted = false, validationError = void 0 }) {
|
|
94
94
|
/**
|
|
95
95
|
* normailize the options schema and values, to avoid prototype pollution
|
|
96
96
|
*/
|
|
@@ -119,6 +119,7 @@ async function createCommandContext({ args = {}, explicit = {}, values = {}, pos
|
|
|
119
119
|
description: command.description,
|
|
120
120
|
omitted,
|
|
121
121
|
callMode,
|
|
122
|
+
commandPath,
|
|
122
123
|
env,
|
|
123
124
|
args: _args,
|
|
124
125
|
explicit,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gunshi/plugin",
|
|
3
3
|
"description": "plugin development kit for gunshi",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.28.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"jsr-exports-lint": "^0.4.1",
|
|
57
57
|
"publint": "^0.3.16",
|
|
58
58
|
"tsdown": "0.15.12",
|
|
59
|
-
"gunshi": "0.
|
|
59
|
+
"gunshi": "0.28.0"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsdown",
|