@gunshi/docs 0.27.0 → 0.27.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gunshi/docs",
3
3
  "description": "Documentation for gunshi",
4
- "version": "0.27.0",
4
+ "version": "0.27.3",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -22,6 +22,34 @@ A [CLI options](../interfaces/CliOptions.md)
22
22
 
23
23
  ## Call Signature
24
24
 
25
+ ```ts
26
+ function cli(
27
+ args,
28
+ entry,
29
+ options?): Promise<string | undefined>;
30
+ ```
31
+
32
+ Run the command.
33
+
34
+ This overload accepts any command-like object using a loose structural type.
35
+ It bypasses TypeScript contravariance issues with callback properties.
36
+
37
+ ### Parameters
38
+
39
+ | Parameter | Type | Description |
40
+ | ------ | ------ | ------ |
41
+ | `args` | `string`[] | Command line arguments |
42
+ | `entry` | [`SubCommandable`](../interfaces/SubCommandable.md) | A command-like object (command, command runner, or lazy command) |
43
+ | `options?` | [`CliOptions`](../interfaces/CliOptions.md)\<[`DefaultGunshiParams`](../type-aliases/DefaultGunshiParams.md)\> | A [CLI options](../interfaces/CliOptions.md) |
44
+
45
+ ### Returns
46
+
47
+ `Promise`\<`string` \| `undefined`\>
48
+
49
+ A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#usagesilent) option, it will return rendered usage string.
50
+
51
+ ## Call Signature
52
+
25
53
  ```ts
26
54
  function cli<G>(
27
55
  args,
@@ -61,6 +61,7 @@ import { cli } from 'gunshi'
61
61
  | [PluginWithExtension](interfaces/PluginWithExtension.md) | Plugin return type with extension, which includes the plugin ID, name, dependencies, and extension. |
62
62
  | [PluginWithoutExtension](interfaces/PluginWithoutExtension.md) | Plugin return type without extension, which includes the plugin ID, name, and dependencies, but no extension. |
63
63
  | [RenderingOptions](interfaces/RenderingOptions.md) | Rendering control options |
64
+ | [SubCommandable](interfaces/SubCommandable.md) | Sub-command entry type for use in subCommands. |
64
65
 
65
66
  ## References
66
67
 
@@ -27,7 +27,7 @@ CLI options of [`cli`](../functions/cli.md) function.
27
27
  | <a id="renderheader"></a> `renderHeader?` | (`ctx`) => `Promise`\<`string`\> \| `null` | Render function the header section in the command usage. |
28
28
  | <a id="renderusage"></a> `renderUsage?` | (`ctx`) => `Promise`\<`string`\> \| `null` | Render function the command usage. |
29
29
  | <a id="rendervalidationerrors"></a> `renderValidationErrors?` | (`ctx`, `error`) => `Promise`\<`string`\> \| `null` | Render function the validation errors. |
30
- | <a id="subcommands"></a> `subCommands?` | \| `Map`\<`string`, \| [`Command`](Command.md)\<`any`\> \| [`LazyCommand`](../type-aliases/LazyCommand.md)\<`any`, \{ \}\>\> \| `Record`\<`string`, \| [`Command`](Command.md)\<`any`\> \| [`LazyCommand`](../type-aliases/LazyCommand.md)\<`any`, \{ \}\>\> | Sub commands. |
30
+ | <a id="subcommands"></a> `subCommands?` | \| `Record`\<`string`, [`SubCommandable`](SubCommandable.md)\> \| `Map`\<`string`, [`SubCommandable`](SubCommandable.md)\> | Sub commands. |
31
31
  | <a id="usageoptiontype"></a> `usageOptionType?` | `boolean` | Whether to display the usage optional argument type. |
32
32
  | <a id="usageoptionvalue"></a> `usageOptionValue?` | `boolean` | Whether to display the optional argument value. |
33
33
  | <a id="usagesilent"></a> `usageSilent?` | `boolean` | Whether to display the command usage. |
@@ -0,0 +1,35 @@
1
+ [gunshi](../../index.md) / [default](../index.md) / SubCommandable
2
+
3
+ # Interface: SubCommandable
4
+
5
+ Sub-command entry type for use in subCommands.
6
+
7
+ This type uses a loose structural match to bypass TypeScript's contravariance issues
8
+ with function parameters, allowing any Command or LazyCommand to be used as a sub-command.
9
+
10
+ ## Since
11
+
12
+ v0.27.1
13
+
14
+ ## Indexable
15
+
16
+ ```ts
17
+ [key: string]: any
18
+ ```
19
+
20
+ Index signature to allow additional properties
21
+
22
+ ## Properties
23
+
24
+ | Property | Type | Description |
25
+ | ------ | ------ | ------ |
26
+ | <a id="args"></a> `args?` | [`Args`](Args.md) \| `Record`\<`string`, `any`\> | Command arguments - accepts any args structure |
27
+ | <a id="commandname"></a> `commandName?` | `string` | Command name for lazy commands |
28
+ | <a id="description"></a> `description?` | `string` | Command description |
29
+ | <a id="entry"></a> `entry?` | `boolean` | Whether this is an entry command |
30
+ | <a id="examples"></a> `examples?` | `string` \| (...`args`) => `any` | Command examples |
31
+ | <a id="internal"></a> `internal?` | `boolean` | Whether this is an internal command |
32
+ | <a id="name"></a> `name?` | `string` | Command name |
33
+ | <a id="rendering"></a> `rendering?` | `any` | Rendering options |
34
+ | <a id="run"></a> `run?` | (...`args`) => `any` | Command runner |
35
+ | <a id="tokebab"></a> `toKebab?` | `boolean` | Whether to convert camelCase to kebab-case |
@@ -144,10 +144,9 @@ const resources = {
144
144
  const command = defineI18n({
145
145
  name: 'greet',
146
146
  description: 'Greet someone in their language',
147
- // Resource function returns translations for the current locale
148
- resource: async ctx => {
149
- const locale = ctx.extensions['g:i18n'].locale
150
- return resources[locale] || resources['en-US']
147
+ // Resource function receives locale and returns translations
148
+ resource: locale => {
149
+ return resources[locale.toString()] || resources['en-US']
151
150
  },
152
151
  args: {
153
152
  name: {
@@ -333,9 +332,8 @@ const resources = {
333
332
  const buildCommand = defineI18n({
334
333
  name: 'build',
335
334
  description: 'Build the project',
336
- resource: async ctx => {
337
- const locale = ctx.extensions['g:i18n'].locale
338
- return resources[locale] || resources['en-US']
335
+ resource: locale => {
336
+ return resources[locale.toString()] || resources['en-US']
339
337
  },
340
338
  args: {
341
339
  mode: {
@@ -704,7 +704,7 @@ The i18n plugin comes with additional packages and helper functions to simplify
704
704
  // Define new command with i18n support
705
705
  const command = defineI18n({
706
706
  name: 'deploy',
707
- resource: async ctx => ({
707
+ resource: locale => ({
708
708
  /* translations */
709
709
  }),
710
710
  run: ctx => {
@@ -714,7 +714,7 @@ The i18n plugin comes with additional packages and helper functions to simplify
714
714
 
715
715
  // Add i18n to existing command
716
716
  const enhancedCommand = withI18nResource(existingCommand, {
717
- resource: async ctx => ({
717
+ resource: locale => ({
718
718
  /* translations */
719
719
  })
720
720
  })
@@ -759,14 +759,14 @@ New playground examples demonstrating:
759
759
  We'd like to thank all the contributors who made this release possible:
760
760
 
761
761
  - [@kazupon](https://github.com/kazupon) - Core maintainer, plugin system architect, i18n extraction, lifecycle hooks
762
- - [@yukukotani](https://github.com/yukukotani) - Fallback to entry command feature (#291)
763
- - [@sushichan044](https://github.com/sushichan044) - Explicit argument detection feature (#232)
764
- - [@43081j](https://github.com/43081j) - Exposed `Plugin` type (#159)
765
- - [@theoephraim](https://github.com/theoephraim) - Documentation improvements (#249)
766
- - [@lukekarrys](https://github.com/lukekarrys) - Documentation updates (#228)
767
- - [@BobbieGoede](https://github.com/BobbieGoede) - Fixed FUNDING.yml (#303)
768
- - [@ryoppippi](https://github.com/ryoppippi) - Docs init CLI feature (#422)
769
- - [@ota-meshi](https://github.com/ota-meshi) - Multiple positional argument usage display improvement (#432)
762
+ - [@yukukotani](https://github.com/yukukotani) - Fallback to entry command feature ([#291](https://github.com/kazupon/gunshi/pull/291))
763
+ - [@sushichan044](https://github.com/sushichan044) - Explicit argument detection feature ([#232](https://github.com/kazupon/gunshi/pull/232))
764
+ - [@43081j](https://github.com/43081j) - Exposed `Plugin` type ([#159](https://github.com/kazupon/gunshi/pull/159))
765
+ - [@theoephraim](https://github.com/theoephraim) - Documentation improvements ([#249](https://github.com/kazupon/gunshi/pull/249))
766
+ - [@lukekarrys](https://github.com/lukekarrys) - Documentation updates ([#228](https://github.com/kazupon/gunshi/pull/228))
767
+ - [@BobbieGoede](https://github.com/BobbieGoede) - Fixed FUNDING.yml ([#303](https://github.com/kazupon/gunshi/pull/303))
768
+ - [@ryoppippi](https://github.com/ryoppippi) - Docs init CLI feature ([#422](https://github.com/kazupon/gunshi/pull/422))
769
+ - [@ota-meshi](https://github.com/ota-meshi) - Multiple positional argument usage display improvement ([#432](https://github.com/kazupon/gunshi/pull/432))
770
770
 
771
771
  Special thanks to the community for feedback and bug reports that helped shape v0.27!
772
772