@gunshi/plugin 0.27.6 → 0.28.2

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 CHANGED
@@ -1272,6 +1272,15 @@ interface CommandContext<G extends GunshiParamsConstraint = DefaultGunshiParams>
1272
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.
1273
1273
  */
1274
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[];
1275
1284
  /**
1276
1285
  * Whether to convert the camel-case style argument name to kebab-case.
1277
1286
  * This context value is set from {@linkcode Command.toKebab} option.
@@ -1413,6 +1422,15 @@ interface Command<G extends GunshiParamsConstraint = DefaultGunshiParams> {
1413
1422
  * @since v0.27.0
1414
1423
  */
1415
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>;
1416
1434
  }
1417
1435
  /**
1418
1436
  * Lazy command interface.
@@ -1483,6 +1501,13 @@ interface SubCommandable {
1483
1501
  * see {@link LazyCommand.commandName}
1484
1502
  */
1485
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>;
1486
1511
  /**
1487
1512
  * Index signature to allow additional properties
1488
1513
  */
@@ -1604,6 +1629,10 @@ interface CommandContextParams<G extends GunshiParams | {
1604
1629
  * Command call mode.
1605
1630
  */
1606
1631
  callMode?: CommandCallMode;
1632
+ /**
1633
+ * The path of nested sub-commands resolved to reach the current command.
1634
+ */
1635
+ commandPath?: string[];
1607
1636
  /**
1608
1637
  * A target command
1609
1638
  */
@@ -1639,6 +1668,7 @@ declare function createCommandContext<G extends GunshiParamsConstraint = Default
1639
1668
  extensions,
1640
1669
  cliOptions,
1641
1670
  callMode,
1671
+ commandPath,
1642
1672
  omitted,
1643
1673
  validationError
1644
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.27.6",
4
+ "version": "0.28.2",
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.27.6"
59
+ "gunshi": "0.28.2"
60
60
  },
61
61
  "scripts": {
62
62
  "build": "tsdown",