@gunshi/docs 0.27.0-beta.4 → 0.27.0-beta.5

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.
Files changed (61) hide show
  1. package/README.md +52 -0
  2. package/package.json +12 -1
  3. package/src/api/context/functions/createCommandContext.md +36 -0
  4. package/src/api/context/index.md +24 -0
  5. package/src/api/context/interfaces/CommandContextParams.md +32 -0
  6. package/src/api/default/classes/DefaultTranslation.md +146 -0
  7. package/src/api/default/functions/cli.md +147 -0
  8. package/src/api/default/functions/parseArgs.md +34 -0
  9. package/src/api/default/functions/plugin.md +98 -0
  10. package/src/api/default/functions/resolveArgs.md +85 -0
  11. package/src/api/default/index.md +124 -0
  12. package/src/api/default/interfaces/ArgSchema.md +57 -0
  13. package/src/api/default/interfaces/ArgToken.md +16 -0
  14. package/src/api/default/interfaces/Args.md +13 -0
  15. package/src/api/default/interfaces/CliOptions.md +34 -0
  16. package/src/api/default/interfaces/Command.md +25 -0
  17. package/src/api/default/interfaces/CommandContext.md +34 -0
  18. package/src/api/default/interfaces/CommandContextExtension.md +23 -0
  19. package/src/api/default/interfaces/CommandEnvironment.md +32 -0
  20. package/src/api/default/interfaces/GunshiParams.md +24 -0
  21. package/src/api/default/interfaces/PluginContext.md +192 -0
  22. package/src/api/default/interfaces/PluginDependency.md +16 -0
  23. package/src/api/default/interfaces/PluginOptions.md +32 -0
  24. package/src/api/default/interfaces/PluginWithExtension.md +44 -0
  25. package/src/api/default/interfaces/PluginWithoutExtension.md +44 -0
  26. package/src/api/default/interfaces/RenderingOptions.md +23 -0
  27. package/src/api/default/type-aliases/ArgValues.md +15 -0
  28. package/src/api/default/type-aliases/Awaitable.md +15 -0
  29. package/src/api/default/type-aliases/CommandCallMode.md +12 -0
  30. package/src/api/default/type-aliases/CommandContextCore.md +19 -0
  31. package/src/api/default/type-aliases/CommandDecorator.md +45 -0
  32. package/src/api/default/type-aliases/CommandExamplesFetcher.md +27 -0
  33. package/src/api/default/type-aliases/CommandLoader.md +28 -0
  34. package/src/api/default/type-aliases/CommandRunner.md +27 -0
  35. package/src/api/default/type-aliases/Commandable.md +18 -0
  36. package/src/api/default/type-aliases/DefaultGunshiParams.md +13 -0
  37. package/src/api/default/type-aliases/ExtendContext.md +13 -0
  38. package/src/api/default/type-aliases/GunshiParamsConstraint.md +22 -0
  39. package/src/api/default/type-aliases/LazyCommand.md +20 -0
  40. package/src/api/default/type-aliases/OnPluginExtension.md +30 -0
  41. package/src/api/default/type-aliases/Plugin.md +53 -0
  42. package/src/api/default/type-aliases/PluginExtension.md +33 -0
  43. package/src/api/default/type-aliases/PluginFunction.md +29 -0
  44. package/src/api/default/type-aliases/Prettify.md +15 -0
  45. package/src/api/default/type-aliases/RendererDecorator.md +35 -0
  46. package/src/api/default/type-aliases/ValidationErrorsDecorator.md +34 -0
  47. package/src/api/default/variables/ANONYMOUS_COMMAND_NAME.md +7 -0
  48. package/src/api/definition/functions/define.md +50 -0
  49. package/src/api/definition/functions/defineWithTypes.md +46 -0
  50. package/src/api/definition/functions/lazy.md +119 -0
  51. package/src/api/definition/functions/lazyWithTypes.md +51 -0
  52. package/src/api/definition/index.md +113 -0
  53. package/src/api/generator/functions/generate.md +32 -0
  54. package/src/api/generator/index.md +23 -0
  55. package/src/api/generator/type-aliases/GenerateOptions.md +15 -0
  56. package/src/api/plugin/index.md +224 -0
  57. package/src/api/plugin/variables/CLI_OPTIONS_DEFAULT.md +7 -0
  58. package/src/api/renderer/functions/renderHeader.md +27 -0
  59. package/src/api/renderer/functions/renderUsage.md +27 -0
  60. package/src/api/renderer/functions/renderValidationErrors.md +28 -0
  61. package/src/api/renderer/index.md +19 -0
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+
2
+ # Gunshi
3
+
4
+ > Modern JavaScript Command-line library
5
+
6
+ Robust, modular, flexible, and localizable CLI library
7
+
8
+ ## Table of Contents
9
+
10
+ ### Introduction
11
+
12
+ - [What's Gunshi?](src/guide/introduction/what-is-gunshi)
13
+ - [Setup](src/guide/introduction/setup)
14
+
15
+
16
+ ### Essentials
17
+
18
+ - [Getting Started](src/guide/essentials/getting-started)
19
+ - [Declarative Configuration](src/guide/essentials/declarative)
20
+ - [Type Safe](src/guide/essentials/type-safe)
21
+ - [Composable](src/guide/essentials/composable)
22
+ - [Lazy & Async](src/guide/essentials/lazy-async)
23
+ - [Auto Usage Generation](src/guide/essentials/auto-usage)
24
+ - [Plugin System](src/guide/essentials/plugin-system)
25
+
26
+
27
+ ### Advanced
28
+
29
+ - [Type System](src/guide/advanced/type-system)
30
+ - [Command Hooks](src/guide/advanced/command-hooks)
31
+ - [Context Extensions](src/guide/advanced/context-extensions)
32
+ - [Custom Rendering](src/guide/advanced/custom-rendering)
33
+ - [Internationalization](src/guide/advanced/internationalization)
34
+ - [Documentation Generation](src/guide/advanced/docs-gen)
35
+ - [Advanced Lazy Loading and Sub-Commands](src/guide/advanced/advanced-lazy-loading)
36
+
37
+
38
+ ### API References
39
+
40
+ - [context](src/api/context/index)
41
+ - [default](src/api/default/index)
42
+ - [definition](src/api/definition/index)
43
+ - [generator](src/api/generator/index)
44
+ - [plugin](src/api/plugin/index)
45
+ - [renderer](src/api/renderer/index)
46
+
47
+
48
+ ### Extra Topics
49
+
50
+ - [Showcase](src/showcase)
51
+
52
+
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-beta.4",
4
+ "version": "0.27.0-beta.5",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -13,6 +13,17 @@
13
13
  "directory": "packages/docs"
14
14
  },
15
15
  "type": "module",
16
+ "keywords": [
17
+ "command",
18
+ "option",
19
+ "cli",
20
+ "argument",
21
+ "args",
22
+ "argv",
23
+ "docs",
24
+ "documentation",
25
+ "llms"
26
+ ],
16
27
  "files": [
17
28
  "README.md",
18
29
  "src/api/context",
@@ -0,0 +1,36 @@
1
+ [gunshi](../../index.md) / [context](../index.md) / createCommandContext
2
+
3
+ # Function: createCommandContext()
4
+
5
+ ```ts
6
+ function createCommandContext<G, V, C, E>(param): Promise<object extends ExtractExtensions<E> ? Readonly<CommandContext<G>> : Readonly<CommandContext<GunshiParams<{
7
+ args: ExtractArgs<G>;
8
+ extensions: ExtractExtensions<E>;
9
+ }>>>>;
10
+ ```
11
+
12
+ Create a command context.
13
+
14
+ ## Type Parameters
15
+
16
+ | Type Parameter | Default type |
17
+ | ------ | ------ |
18
+ | `G` *extends* [`GunshiParamsConstraint`](../../default/type-aliases/GunshiParamsConstraint.md) | [`DefaultGunshiParams`](../../default/type-aliases/DefaultGunshiParams.md) |
19
+ | `V` *extends* `object` | [`ArgValues`](../../default/type-aliases/ArgValues.md)\<`ExtractArgs`\<`G`\>\> |
20
+ | `C` *extends* \| [`Command`](../../default/interfaces/Command.md)\<`G`\> \| [`LazyCommand`](../../default/type-aliases/LazyCommand.md)\<`G`\> | [`Command`](../../default/interfaces/Command.md)\<`G`\> |
21
+ | `E` *extends* `Record`\<`string`, [`CommandContextExtension`](../../default/interfaces/CommandContextExtension.md)\<\{ \}\>\> | `object` |
22
+
23
+ ## Parameters
24
+
25
+ | Parameter | Type | Description |
26
+ | ------ | ------ | ------ |
27
+ | `param` | [`CommandContextParams`](../interfaces/CommandContextParams.md)\<`G`, `V`, `C`, `E`\> | A [parameters](../interfaces/CommandContextParams.md) to create a command context. |
28
+
29
+ ## Returns
30
+
31
+ `Promise`\<`object` *extends* `ExtractExtensions`\<`E`\> ? `Readonly`\<[`CommandContext`](../../default/interfaces/CommandContext.md)\<`G`\>\> : `Readonly`\<[`CommandContext`](../../default/interfaces/CommandContext.md)\<[`GunshiParams`](../../default/interfaces/GunshiParams.md)\<\{
32
+ `args`: `ExtractArgs`\<`G`\>;
33
+ `extensions`: `ExtractExtensions`\<`E`\>;
34
+ \}\>\>\>\>
35
+
36
+ A [command context](../../default/interfaces/CommandContext.md), which is readonly.
@@ -0,0 +1,24 @@
1
+ [gunshi](../index.md) / context
2
+
3
+ # context
4
+
5
+ The entry for gunshi context.
6
+ This module is exported for the purpose of testing the command.
7
+
8
+ ## Example
9
+
10
+ ```js
11
+ import { createCommandContext } from 'gunshi/context'
12
+ ```
13
+
14
+ ## Functions
15
+
16
+ | Function | Description |
17
+ | ------ | ------ |
18
+ | [createCommandContext](functions/createCommandContext.md) | Create a command context. |
19
+
20
+ ## Interfaces
21
+
22
+ | Interface | Description |
23
+ | ------ | ------ |
24
+ | [CommandContextParams](interfaces/CommandContextParams.md) | Parameters of [createCommandContext](functions/createCommandContext.md) |
@@ -0,0 +1,32 @@
1
+ [gunshi](../../index.md) / [context](../index.md) / CommandContextParams
2
+
3
+ # Interface: CommandContextParams\<G, V, C, E\>
4
+
5
+ Parameters of [createCommandContext](../functions/createCommandContext.md)
6
+
7
+ ## Type Parameters
8
+
9
+ | Type Parameter | Default type |
10
+ | ------ | ------ |
11
+ | `G` *extends* \| [`GunshiParams`](../../default/interfaces/GunshiParams.md) \| \{ `args`: [`Args`](../../default/interfaces/Args.md); \} \| \{ `extensions`: [`ExtendContext`](../../default/type-aliases/ExtendContext.md); \} | - |
12
+ | `V` *extends* [`ArgValues`](../../default/type-aliases/ArgValues.md)\<`ExtractArgs`\<`G`\>\> | - |
13
+ | `C` *extends* \| [`Command`](../../default/interfaces/Command.md)\<`G`\> \| [`LazyCommand`](../../default/type-aliases/LazyCommand.md)\<`G`\> | [`Command`](../../default/interfaces/Command.md)\<`G`\> |
14
+ | `E` *extends* `Record`\<`string`, [`CommandContextExtension`](../../default/interfaces/CommandContextExtension.md)\> | `Record`\<`string`, [`CommandContextExtension`](../../default/interfaces/CommandContextExtension.md)\> |
15
+
16
+ ## Properties
17
+
18
+ | Property | Type | Description |
19
+ | ------ | ------ | ------ |
20
+ | <a id="args"></a> `args?` | `ExtractArgs`\<`G`\> | An arguments of target command |
21
+ | <a id="argv"></a> `argv?` | `string`[] | Original command line arguments |
22
+ | <a id="callmode"></a> `callMode?` | [`CommandCallMode`](../../default/type-aliases/CommandCallMode.md) | Command call mode. |
23
+ | <a id="clioptions"></a> `cliOptions?` | [`CliOptions`](../../default/interfaces/CliOptions.md)\<`G`\> | A command options, which is spicialized from `cli` function |
24
+ | <a id="command"></a> `command?` | `C` | A target command |
25
+ | <a id="explicit"></a> `explicit?` | `ArgExplicitlyProvided`\<`ExtractArgs`\<`G`\>\> | Explicitly provided arguments |
26
+ | <a id="extensions"></a> `extensions?` | `E` | Plugin extensions to apply as the command context extension. |
27
+ | <a id="omitted"></a> `omitted?` | `boolean` | Whether the command is omitted |
28
+ | <a id="positionals"></a> `positionals?` | `string`[] | A positionals arguments, which passed to the target command |
29
+ | <a id="rest"></a> `rest?` | `string`[] | A rest arguments, which passed to the target command |
30
+ | <a id="tokens"></a> `tokens?` | [`ArgToken`](../../default/interfaces/ArgToken.md)[] | Argument tokens that are parsed by the `parseArgs` function |
31
+ | <a id="validationerror"></a> `validationError?` | `AggregateError` | Validation error from argument parsing. |
32
+ | <a id="values"></a> `values?` | `V` | A values of target command |
@@ -0,0 +1,146 @@
1
+ [gunshi](../../index.md) / [default](../index.md) / DefaultTranslation
2
+
3
+ # Class: DefaultTranslation
4
+
5
+ Default implementation of `TranslationAdapter`.
6
+
7
+ ## Implements
8
+
9
+ - `TranslationAdapter`
10
+
11
+ ## Constructors
12
+
13
+ ### Constructor
14
+
15
+ ```ts
16
+ new DefaultTranslation(options): DefaultTranslation;
17
+ ```
18
+
19
+ Creates a new instance of DefaultTranslation.
20
+
21
+ #### Parameters
22
+
23
+ | Parameter | Type | Description |
24
+ | ------ | ------ | ------ |
25
+ | `options` | `TranslationAdapterFactoryOptions` | Options for the translation adapter, see `TranslationAdapterFactoryOptions` |
26
+
27
+ #### Returns
28
+
29
+ `DefaultTranslation`
30
+
31
+ ## Methods
32
+
33
+ ### getMessage()
34
+
35
+ ```ts
36
+ getMessage(locale, key): string | undefined;
37
+ ```
38
+
39
+ Get a message of locale.
40
+
41
+ #### Parameters
42
+
43
+ | Parameter | Type | Description |
44
+ | ------ | ------ | ------ |
45
+ | `locale` | `string` | A locale of message (BCP 47 language tag) |
46
+ | `key` | `string` | A key of message resource |
47
+
48
+ #### Returns
49
+
50
+ `string` \| `undefined`
51
+
52
+ A message of locale. If message not found, return `undefined`.
53
+
54
+ #### Implementation of
55
+
56
+ ```ts
57
+ TranslationAdapter.getMessage
58
+ ```
59
+
60
+ ***
61
+
62
+ ### getResource()
63
+
64
+ ```ts
65
+ getResource(locale): Record<string, string> | undefined;
66
+ ```
67
+
68
+ Get a resource of locale.
69
+
70
+ #### Parameters
71
+
72
+ | Parameter | Type | Description |
73
+ | ------ | ------ | ------ |
74
+ | `locale` | `string` | A locale of resource (BCP 47 language tag) |
75
+
76
+ #### Returns
77
+
78
+ `Record`\<`string`, `string`\> \| `undefined`
79
+
80
+ A resource of locale. If resource not found, return `undefined`.
81
+
82
+ #### Implementation of
83
+
84
+ ```ts
85
+ TranslationAdapter.getResource
86
+ ```
87
+
88
+ ***
89
+
90
+ ### setResource()
91
+
92
+ ```ts
93
+ setResource(locale, resource): void;
94
+ ```
95
+
96
+ Set a resource of locale.
97
+
98
+ #### Parameters
99
+
100
+ | Parameter | Type | Description |
101
+ | ------ | ------ | ------ |
102
+ | `locale` | `string` | A locale of resource (BCP 47 language tag) |
103
+ | `resource` | `Record`\<`string`, `string`\> | A resource of locale |
104
+
105
+ #### Returns
106
+
107
+ `void`
108
+
109
+ #### Implementation of
110
+
111
+ ```ts
112
+ TranslationAdapter.setResource
113
+ ```
114
+
115
+ ***
116
+
117
+ ### translate()
118
+
119
+ ```ts
120
+ translate(
121
+ locale,
122
+ key,
123
+ values): string | undefined;
124
+ ```
125
+
126
+ Translate a message.
127
+
128
+ #### Parameters
129
+
130
+ | Parameter | Type | Description |
131
+ | ------ | ------ | ------ |
132
+ | `locale` | `string` | A locale of message (BCP 47 language tag) |
133
+ | `key` | `string` | A key of message resource |
134
+ | `values` | `Record`\<`string`, `unknown`\> | A values to interpolate in the message |
135
+
136
+ #### Returns
137
+
138
+ `string` \| `undefined`
139
+
140
+ A translated message, if message is not translated, return `undefined`.
141
+
142
+ #### Implementation of
143
+
144
+ ```ts
145
+ TranslationAdapter.translate
146
+ ```
@@ -0,0 +1,147 @@
1
+ [gunshi](../../index.md) / [default](../index.md) / cli
2
+
3
+ # Function: cli()
4
+
5
+ Run the command.
6
+
7
+ ## Type Param
8
+
9
+ A type extending [`GunshiParams`](../interfaces/GunshiParams.md) to specify the shape of command and cli options.
10
+
11
+ ## Param
12
+
13
+ Command line arguments
14
+
15
+ ## Param
16
+
17
+ A [entry command](../interfaces/Command.md), an [inline command runner](../type-aliases/CommandRunner.md), or a [lazily-loaded command](../type-aliases/LazyCommand.md)
18
+
19
+ ## Param
20
+
21
+ A [CLI options](../interfaces/CliOptions.md)
22
+
23
+ ## Call Signature
24
+
25
+ ```ts
26
+ function cli<G>(
27
+ args,
28
+ entry,
29
+ options?): Promise<string | undefined>;
30
+ ```
31
+
32
+ Run the command.
33
+
34
+ ### Type Parameters
35
+
36
+ | Type Parameter | Description |
37
+ | ------ | ------ |
38
+ | `G` *extends* [`GunshiParamsConstraint`](../type-aliases/GunshiParamsConstraint.md) | A type extending [`GunshiParams`](../interfaces/GunshiParams.md) to specify the shape of command and cli options. |
39
+
40
+ ### Parameters
41
+
42
+ | Parameter | Type | Description |
43
+ | ------ | ------ | ------ |
44
+ | `args` | `string`[] | Command line arguments |
45
+ | `entry` | \| [`Command`](../interfaces/Command.md)\<`G`\> \| [`CommandRunner`](../type-aliases/CommandRunner.md)\<`G`\> \| [`LazyCommand`](../type-aliases/LazyCommand.md)\<`G`\> | A [entry command](../interfaces/Command.md), an [inline command runner](../type-aliases/CommandRunner.md), or a [lazily-loaded command](../type-aliases/LazyCommand.md) |
46
+ | `options?` | [`CliOptions`](../interfaces/CliOptions.md)\<`G`\> | A [CLI options](../interfaces/CliOptions.md) |
47
+
48
+ ### Returns
49
+
50
+ `Promise`\<`string` \| `undefined`\>
51
+
52
+ A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#usagesilent) option, it will return rendered usage string.
53
+
54
+ ## Call Signature
55
+
56
+ ```ts
57
+ function cli<A, G>(
58
+ args,
59
+ entry,
60
+ options?): Promise<string | undefined>;
61
+ ```
62
+
63
+ Run the command.
64
+
65
+ ### Type Parameters
66
+
67
+ | Type Parameter | Default type | Description |
68
+ | ------ | ------ | ------ |
69
+ | `A` *extends* [`Args`](../interfaces/Args.md) | [`Args`](../interfaces/Args.md) | The type of [`arguments`](../interfaces/Args.md) defined in the command and cli options. |
70
+ | `G` *extends* [`GunshiParams`](../interfaces/GunshiParams.md)\<\{ `args`: [`Args`](../interfaces/Args.md); `extensions`: \{ \}; \}\> | `object` | - |
71
+
72
+ ### Parameters
73
+
74
+ | Parameter | Type | Description |
75
+ | ------ | ------ | ------ |
76
+ | `args` | `string`[] | Command line arguments |
77
+ | `entry` | \| [`Command`](../interfaces/Command.md)\<`G`\> \| [`CommandRunner`](../type-aliases/CommandRunner.md)\<`G`\> \| [`LazyCommand`](../type-aliases/LazyCommand.md)\<`G`\> | A [entry command](../interfaces/Command.md), an [inline command runner](../type-aliases/CommandRunner.md), or a [lazily-loaded command](../type-aliases/LazyCommand.md) |
78
+ | `options?` | [`CliOptions`](../interfaces/CliOptions.md)\<`G`\> | A [CLI options](../interfaces/CliOptions.md) |
79
+
80
+ ### Returns
81
+
82
+ `Promise`\<`string` \| `undefined`\>
83
+
84
+ A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#usagesilent) option, it will return rendered usage string.
85
+
86
+ ## Call Signature
87
+
88
+ ```ts
89
+ function cli<E, G>(
90
+ args,
91
+ entry,
92
+ options?): Promise<string | undefined>;
93
+ ```
94
+
95
+ Run the command.
96
+
97
+ ### Type Parameters
98
+
99
+ | Type Parameter | Default type | Description |
100
+ | ------ | ------ | ------ |
101
+ | `E` *extends* [`ExtendContext`](../type-aliases/ExtendContext.md) | [`ExtendContext`](../type-aliases/ExtendContext.md) | An [`ExtendContext`](../type-aliases/ExtendContext.md) type to specify the shape of command and cli options. |
102
+ | `G` *extends* [`GunshiParams`](../interfaces/GunshiParams.md)\<\{ `args`: [`Args`](../interfaces/Args.md); `extensions`: \{ \}; \}\> | `object` | - |
103
+
104
+ ### Parameters
105
+
106
+ | Parameter | Type | Description |
107
+ | ------ | ------ | ------ |
108
+ | `args` | `string`[] | Command line arguments |
109
+ | `entry` | \| [`Command`](../interfaces/Command.md)\<`G`\> \| [`CommandRunner`](../type-aliases/CommandRunner.md)\<`G`\> \| [`LazyCommand`](../type-aliases/LazyCommand.md)\<`G`\> | A [entry command](../interfaces/Command.md), an [inline command runner](../type-aliases/CommandRunner.md), or a [lazily-loaded command](../type-aliases/LazyCommand.md) |
110
+ | `options?` | [`CliOptions`](../interfaces/CliOptions.md)\<`G`\> | A [CLI options](../interfaces/CliOptions.md) |
111
+
112
+ ### Returns
113
+
114
+ `Promise`\<`string` \| `undefined`\>
115
+
116
+ A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#usagesilent) option, it will return rendered usage string.
117
+
118
+ ## Call Signature
119
+
120
+ ```ts
121
+ function cli<G>(
122
+ args,
123
+ entry,
124
+ options?): Promise<string | undefined>;
125
+ ```
126
+
127
+ Run the command.
128
+
129
+ ### Type Parameters
130
+
131
+ | Type Parameter | Default type | Description |
132
+ | ------ | ------ | ------ |
133
+ | `G` *extends* [`GunshiParams`](../interfaces/GunshiParams.md)\<\{ `args`: [`Args`](../interfaces/Args.md); `extensions`: \{ \}; \}\> | [`DefaultGunshiParams`](../type-aliases/DefaultGunshiParams.md) | A type extending [`GunshiParams`](../interfaces/GunshiParams.md) to specify the shape of command and cli options. |
134
+
135
+ ### Parameters
136
+
137
+ | Parameter | Type | Description |
138
+ | ------ | ------ | ------ |
139
+ | `args` | `string`[] | Command line arguments |
140
+ | `entry` | \| [`Command`](../interfaces/Command.md)\<`G`\> \| [`CommandRunner`](../type-aliases/CommandRunner.md)\<`G`\> \| [`LazyCommand`](../type-aliases/LazyCommand.md)\<`G`\> | A [entry command](../interfaces/Command.md), an [inline command runner](../type-aliases/CommandRunner.md), or a [lazily-loaded command](../type-aliases/LazyCommand.md) |
141
+ | `options?` | [`CliOptions`](../interfaces/CliOptions.md)\<`G`\> | A [CLI options](../interfaces/CliOptions.md) |
142
+
143
+ ### Returns
144
+
145
+ `Promise`\<`string` \| `undefined`\>
146
+
147
+ A rendered usage or undefined. if you will use [`CliOptions.usageSilent`](../interfaces/CliOptions.md#usagesilent) option, it will return rendered usage string.
@@ -0,0 +1,34 @@
1
+ [gunshi](../../index.md) / [default](../index.md) / parseArgs
2
+
3
+ # Function: parseArgs()
4
+
5
+ ```ts
6
+ function parseArgs(args, options?): ArgToken[];
7
+ ```
8
+
9
+ Parse command line arguments.
10
+
11
+ ## Parameters
12
+
13
+ | Parameter | Type | Description |
14
+ | ------ | ------ | ------ |
15
+ | `args` | `string`[] | command line arguments |
16
+ | `options?` | `ParserOptions` | parse options, about details see ParserOptions |
17
+
18
+ ## Returns
19
+
20
+ [`ArgToken`](../interfaces/ArgToken.md)[]
21
+
22
+ Argument tokens.
23
+
24
+ ## Example
25
+
26
+ ```js
27
+ import { parseArgs } from 'args-tokens' // for Node.js and Bun
28
+ // import { parseArgs } from 'jsr:@kazupon/args-tokens' // for Deno
29
+
30
+ const tokens = parseArgs(['--foo', 'bar', '-x', '--bar=baz'])
31
+ // do something with using tokens
32
+ // ...
33
+ console.log('tokens:', tokens)
34
+ ```
@@ -0,0 +1,98 @@
1
+ [gunshi](../../index.md) / [default](../index.md) / plugin
2
+
3
+ # Function: plugin()
4
+
5
+ Define a plugin
6
+
7
+ ## Param
8
+
9
+ [`plugin options`](../interfaces/PluginOptions.md)
10
+
11
+ ## Since
12
+
13
+ v0.27.0
14
+
15
+ ## Call Signature
16
+
17
+ ```ts
18
+ function plugin<Context, Id, Deps, Extension, ResolvedDepExtensions, PluginExt, MergedExtensions>(options): PluginWithExtension<Awaited<ReturnType<PluginExt>>>;
19
+ ```
20
+
21
+ Define a plugin with extension compatibility and typed dependency extensions
22
+
23
+ ### Type Parameters
24
+
25
+ | Type Parameter | Default type | Description |
26
+ | ------ | ------ | ------ |
27
+ | `Context` *extends* [`ExtendContext`](../type-aliases/ExtendContext.md) | `object` | A type extending [`ExtendContext`](../type-aliases/ExtendContext.md) to specify the shape of plugin dependency extensions. |
28
+ | `Id` *extends* `string` | `string` | A string type to specify the plugin ID. |
29
+ | `Deps` *extends* readonly (`string` \| [`PluginDependency`](../interfaces/PluginDependency.md))[] | \[\] | A readonly array of [`PluginDependency`](../interfaces/PluginDependency.md) or string to specify the plugin dependencies. |
30
+ | `Extension` *extends* `object` | `object` | A type to specify the shape of the plugin extension object. |
31
+ | `ResolvedDepExtensions` *extends* [`GunshiParams`](../interfaces/GunshiParams.md)\<\{ `args`: [`Args`](../interfaces/Args.md); `extensions`: \{ \}; \}\> | [`GunshiParams`](../interfaces/GunshiParams.md)\<\{ `args`: [`Args`](../interfaces/Args.md); `extensions`: `InferDependencyExtensions`\<`Deps`, `Context`\>; \}\> | - |
32
+ | `PluginExt` *extends* [`PluginExtension`](../type-aliases/PluginExtension.md)\<`Extension`, [`DefaultGunshiParams`](../type-aliases/DefaultGunshiParams.md)\> | [`PluginExtension`](../type-aliases/PluginExtension.md)\<`Extension`, `ResolvedDepExtensions`\> | - |
33
+ | `MergedExtensions` *extends* [`GunshiParams`](../interfaces/GunshiParams.md)\<\{ `args`: [`Args`](../interfaces/Args.md); `extensions`: \{ \}; \}\> | [`GunshiParams`](../interfaces/GunshiParams.md)\<\{ `args`: [`Args`](../interfaces/Args.md); `extensions`: `MergeExtension`\<`Id`, `InferDependencyExtensions`\<`Deps`, `Context`\>, `Awaited`\<`ReturnType`\<`PluginExt`\>\>\>; \}\> | - |
34
+
35
+ ### Parameters
36
+
37
+ | Parameter | Type | Description |
38
+ | ------ | ------ | ------ |
39
+ | `options` | \{ `dependencies?`: `Deps`; `extension`: `PluginExt`; `id`: `Id`; `name?`: `string`; `onExtension?`: [`OnPluginExtension`](../type-aliases/OnPluginExtension.md)\<`MergedExtensions`\>; `setup?`: (`ctx`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\>; \} | [`plugin options`](../interfaces/PluginOptions.md) |
40
+ | `options.dependencies?` | `Deps` | - |
41
+ | `options.extension` | `PluginExt` | - |
42
+ | `options.id` | `Id` | - |
43
+ | `options.name?` | `string` | - |
44
+ | `options.onExtension?` | [`OnPluginExtension`](../type-aliases/OnPluginExtension.md)\<`MergedExtensions`\> | - |
45
+ | `options.setup?` | (`ctx`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> | - |
46
+
47
+ ### Returns
48
+
49
+ [`PluginWithExtension`](../interfaces/PluginWithExtension.md)\<`Awaited`\<`ReturnType`\<`PluginExt`\>\>\>
50
+
51
+ A defined plugin with extension
52
+
53
+ ### Since
54
+
55
+ v0.27.0
56
+
57
+ ## Call Signature
58
+
59
+ ```ts
60
+ function plugin<Context, Id, Deps, Extension, ResolvedDepExtensions, PluginExt, MergedExtensions>(options): PluginWithoutExtension<{
61
+ }>;
62
+ ```
63
+
64
+ Define a plugin without extension and typed dependency extensions
65
+
66
+ ### Type Parameters
67
+
68
+ | Type Parameter | Default type | Description |
69
+ | ------ | ------ | ------ |
70
+ | `Context` *extends* [`ExtendContext`](../type-aliases/ExtendContext.md) | `object` | A type extending [`ExtendContext`](../type-aliases/ExtendContext.md) to specify the shape of plugin dependency extensions. |
71
+ | `Id` *extends* `string` | `string` | A string type to specify the plugin ID. |
72
+ | `Deps` *extends* readonly (`string` \| [`PluginDependency`](../interfaces/PluginDependency.md))[] | \[\] | A readonly array of [`PluginDependency`](../interfaces/PluginDependency.md) or string to specify the plugin dependencies. |
73
+ | `Extension` *extends* `Record`\<`string`, `unknown`\> | `object` | A type to specify the shape of the plugin extension object. |
74
+ | `ResolvedDepExtensions` *extends* [`GunshiParams`](../interfaces/GunshiParams.md)\<\{ `args`: [`Args`](../interfaces/Args.md); `extensions`: \{ \}; \}\> | [`GunshiParams`](../interfaces/GunshiParams.md)\<\{ `args`: [`Args`](../interfaces/Args.md); `extensions`: `InferDependencyExtensions`\<`Deps`, `Context`\>; \}\> | - |
75
+ | `PluginExt` *extends* [`PluginExtension`](../type-aliases/PluginExtension.md)\<`Extension`, [`DefaultGunshiParams`](../type-aliases/DefaultGunshiParams.md)\> | [`PluginExtension`](../type-aliases/PluginExtension.md)\<`Extension`, `ResolvedDepExtensions`\> | - |
76
+ | `MergedExtensions` *extends* [`GunshiParams`](../interfaces/GunshiParams.md)\<\{ `args`: [`Args`](../interfaces/Args.md); `extensions`: \{ \}; \}\> | [`GunshiParams`](../interfaces/GunshiParams.md)\<\{ `args`: [`Args`](../interfaces/Args.md); `extensions`: `MergeExtension`\<`Id`, `InferDependencyExtensions`\<`Deps`, `Context`\>, `Awaited`\<`ReturnType`\<`PluginExt`\>\>\>; \}\> | - |
77
+
78
+ ### Parameters
79
+
80
+ | Parameter | Type | Description |
81
+ | ------ | ------ | ------ |
82
+ | `options` | \{ `dependencies?`: `Deps`; `id`: `Id`; `name?`: `string`; `onExtension?`: [`OnPluginExtension`](../type-aliases/OnPluginExtension.md)\<`MergedExtensions`\>; `setup?`: (`ctx`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\>; \} | [`plugin options`](../interfaces/PluginOptions.md) without extension |
83
+ | `options.dependencies?` | `Deps` | - |
84
+ | `options.id` | `Id` | - |
85
+ | `options.name?` | `string` | - |
86
+ | `options.onExtension?` | [`OnPluginExtension`](../type-aliases/OnPluginExtension.md)\<`MergedExtensions`\> | - |
87
+ | `options.setup?` | (`ctx`) => [`Awaitable`](../type-aliases/Awaitable.md)\<`void`\> | - |
88
+
89
+ ### Returns
90
+
91
+ [`PluginWithoutExtension`](../interfaces/PluginWithoutExtension.md)\<\{
92
+ \}\>
93
+
94
+ A defined plugin without extension
95
+
96
+ ### Since
97
+
98
+ v0.27.0
@@ -0,0 +1,85 @@
1
+ [gunshi](../../index.md) / [default](../index.md) / resolveArgs
2
+
3
+ # Function: resolveArgs()
4
+
5
+ ```ts
6
+ function resolveArgs<A>(
7
+ args,
8
+ tokens,
9
+ resolveArgs?): object;
10
+ ```
11
+
12
+ Resolve command line arguments.
13
+
14
+ ## Type Parameters
15
+
16
+ | Type Parameter | Description |
17
+ | ------ | ------ |
18
+ | `A` *extends* [`Args`](../interfaces/Args.md) | [Arguments](../interfaces/Args.md), which is an object that defines the command line arguments. |
19
+
20
+ ## Parameters
21
+
22
+ | Parameter | Type | Description |
23
+ | ------ | ------ | ------ |
24
+ | `args` | `A` | An arguments that contains [arguments schema](../interfaces/ArgSchema.md). |
25
+ | `tokens` | [`ArgToken`](../interfaces/ArgToken.md)[] | An array of [tokens](../interfaces/ArgToken.md). |
26
+ | `resolveArgs?` | `ResolveArgs` | An arguments that contains ResolveArgs \| resolve arguments. |
27
+
28
+ ## Returns
29
+
30
+ `object`
31
+
32
+ An object that contains the values of the arguments, positional arguments, rest arguments, AggregateError \| validation errors, and explicit provision status.
33
+
34
+ ### error
35
+
36
+ ```ts
37
+ error: AggregateError | undefined;
38
+ ```
39
+
40
+ ### explicit
41
+
42
+ ```ts
43
+ explicit: ArgExplicitlyProvided<A>;
44
+ ```
45
+
46
+ ### positionals
47
+
48
+ ```ts
49
+ positionals: string[];
50
+ ```
51
+
52
+ ### rest
53
+
54
+ ```ts
55
+ rest: string[];
56
+ ```
57
+
58
+ ### values
59
+
60
+ ```ts
61
+ values: ArgValues<A>;
62
+ ```
63
+
64
+ ## Example
65
+
66
+ ```typescript
67
+ // passed tokens: --port 3000
68
+
69
+ const { values, explicit } = resolveArgs({
70
+ port: {
71
+ type: 'number',
72
+ default: 8080
73
+ },
74
+ host: {
75
+ type: 'string',
76
+ default: 'localhost'
77
+ }
78
+ }, parsedTokens)
79
+
80
+ values.port // 3000
81
+ values.host // 'localhost'
82
+
83
+ explicit.port // true (explicitly provided)
84
+ explicit.host // false (not provided, fallback to default)
85
+ ```