gunshi 0.36.0 → 0.37.1
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/README.md +9 -8
- package/lib/agent.js +17 -8
- package/lib/bone.d.ts +2 -2
- package/lib/bone.js +1 -1
- package/lib/{cli-DnXk5aCq.js → cli-8lpU57Wl.js} +4 -4
- package/lib/combinators.d.ts +2 -2
- package/lib/combinators.js +3 -3
- package/lib/context.d.ts +2 -2
- package/lib/{core-CbE1I4Jl.js → core-vmpEqkpT.js} +3 -3
- package/lib/definition.d.ts +2 -2
- package/lib/{error-xSnOOdnr.js → error-BxeGn0JU.js} +2 -2
- package/lib/{error-6srXBX7u.d.ts → error-DdRv50OI.d.ts} +1 -1
- package/lib/generator.d.ts +1 -1
- package/lib/generator.js +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +5 -5
- package/lib/{plugin-DhJZVIbl.js → plugin-BY44BdcY.js} +1 -1
- package/lib/plugin.d.ts +3 -3
- package/lib/plugin.js +3 -3
- package/lib/renderer.d.ts +1 -1
- package/lib/renderer.js +1 -1
- package/lib/{resolver-CgkhQ6Tt.d.ts → resolver-CKLHkuQa.d.ts} +2 -2
- package/lib/{resolver-UFOtObbe.js → resolver-UjEQwV-U.js} +24 -12
- package/lib/{src-DbfZvEe0.js → src-a-JpaUM5.js} +6 -7
- package/lib/{types-CD5eRJFK.d.ts → types-8Qh1S2q6.d.ts} +1 -1
- package/lib/{utils-BKhsrjPW.js → utils-CfOBA5zn.js} +1 -1
- package/lib/utils.d.ts +2 -2
- package/lib/utils.js +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ Gunshi is a modern javascript command-line library
|
|
|
17
17
|
|
|
18
18
|
<!-- eslint-enable markdown/no-missing-label-refs -->
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## Features
|
|
21
21
|
|
|
22
22
|
Gunshi is designed to simplify the creation of modern command-line interfaces:
|
|
23
23
|
|
|
@@ -26,9 +26,10 @@ Gunshi is designed to simplify the creation of modern command-line interfaces:
|
|
|
26
26
|
- 🧩 **Composable & Lazy**: Create modular sub-commands with context sharing and lazy loading for better performance.
|
|
27
27
|
- 🎨 **Flexible Rendering**: Customize usage generation, validation errors, and help messages with pluggable renderers.
|
|
28
28
|
- 🌍 **Internationalization**: Built with global users in mind, featuring locale-aware design, resource management, and multi-language support.
|
|
29
|
+
- 🤖 **Agent-aware**: Detect AI coding-agent environments through the stable [`gunshi/agent`](https://gunshi.dev/guide/advanced/ai-agent-detection) utility without changing CLI behavior automatically.
|
|
29
30
|
- 🔌 **Pluggable**: Extensible plugin system with dependency management and lifecycle hooks for modular CLI development.
|
|
30
31
|
|
|
31
|
-
##
|
|
32
|
+
## Installation
|
|
32
33
|
|
|
33
34
|
```sh
|
|
34
35
|
# npm
|
|
@@ -47,7 +48,7 @@ deno add jsr:@gunshi/gunshi
|
|
|
47
48
|
bun add gunshi
|
|
48
49
|
```
|
|
49
50
|
|
|
50
|
-
##
|
|
51
|
+
## Usage
|
|
51
52
|
|
|
52
53
|
```js
|
|
53
54
|
import { cli } from 'gunshi'
|
|
@@ -94,7 +95,7 @@ await cli(process.argv.slice(2), command, {
|
|
|
94
95
|
|
|
95
96
|
About more details and usage, see [documentations](https://gunshi.dev)
|
|
96
97
|
|
|
97
|
-
##
|
|
98
|
+
## Showcases
|
|
98
99
|
|
|
99
100
|
- [pnpmc](https://github.com/kazupon/pnpmc): PNPM Catalogs Tooling
|
|
100
101
|
- [sourcemap-publisher](https://github.com/es-tooling/sourcemap-publisher): A tool to publish sourcemaps externally and rewrite sourcemap URLs at pre-publish time
|
|
@@ -103,11 +104,11 @@ About more details and usage, see [documentations](https://gunshi.dev)
|
|
|
103
104
|
- [ccusage](https://github.com/ryoppippi/ccusage): A CLI tool for analyzing Claude Code usage from local JSONL files
|
|
104
105
|
- [varlock](https://github.com/dmno-dev/varlock): Enhanced .env file loader, using @decorator style comments to add validation, type-safety, and more
|
|
105
106
|
|
|
106
|
-
##
|
|
107
|
+
## Contributing guidelines
|
|
107
108
|
|
|
108
109
|
If you are interested in contributing to `gunshi`, I highly recommend checking out [the contributing guidelines](/CONTRIBUTING.md) here. You'll find all the relevant information such as [how to make a PR](/CONTRIBUTING.md#pull-request-guidelines), [how to setup development](/CONTRIBUTING.md#development-setup)) etc., there.
|
|
109
110
|
|
|
110
|
-
##
|
|
111
|
+
## Credits
|
|
111
112
|
|
|
112
113
|
This project is inspired and powered by:
|
|
113
114
|
|
|
@@ -117,7 +118,7 @@ This project is inspired and powered by:
|
|
|
117
118
|
|
|
118
119
|
Thank you!
|
|
119
120
|
|
|
120
|
-
##
|
|
121
|
+
## Sponsors
|
|
121
122
|
|
|
122
123
|
The development of Gunshi is supported by my OSS sponsors!
|
|
123
124
|
|
|
@@ -127,7 +128,7 @@ The development of Gunshi is supported by my OSS sponsors!
|
|
|
127
128
|
</a>
|
|
128
129
|
</p>
|
|
129
130
|
|
|
130
|
-
##
|
|
131
|
+
## License
|
|
131
132
|
|
|
132
133
|
[MIT](http://opensource.org/licenses/MIT)
|
|
133
134
|
|
package/lib/agent.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
//#region ../../node_modules/.pnpm/std-env@4.1.0/node_modules/std-env/dist/index.mjs
|
|
2
|
-
const e = globalThis.process?.env || Object.create(null)
|
|
2
|
+
const e = globalThis.process?.env || Object.create(null);
|
|
3
|
+
const t = globalThis.process || { env: e };
|
|
4
|
+
const n = t !== void 0 && t.env && t.env.NODE_ENV || void 0;
|
|
5
|
+
const r = [
|
|
3
6
|
[`claude`, [`CLAUDECODE`, `CLAUDE_CODE`]],
|
|
4
7
|
[`replit`, [`REPL_ID`]],
|
|
5
8
|
[`gemini`, [`GEMINI_CLI`]],
|
|
@@ -160,7 +163,14 @@ const S = /^win/i.test(p);
|
|
|
160
163
|
!e.NO_COLOR && (e.FORCE_COLOR || (h || S) && e.TERM);
|
|
161
164
|
const E = (t.versions?.node || ``).replace(/^v/, ``) || null;
|
|
162
165
|
Number(E?.split(`.`)[0]);
|
|
163
|
-
const O = !!t?.versions?.node
|
|
166
|
+
const O = !!t?.versions?.node;
|
|
167
|
+
const k = `Bun` in globalThis;
|
|
168
|
+
const A = `Deno` in globalThis;
|
|
169
|
+
const j = `fastly` in globalThis;
|
|
170
|
+
const M = `Netlify` in globalThis;
|
|
171
|
+
const N = `EdgeRuntime` in globalThis;
|
|
172
|
+
const P = globalThis.navigator?.userAgent === `Cloudflare-Workers`;
|
|
173
|
+
const F = [
|
|
164
174
|
[M, `netlify`],
|
|
165
175
|
[N, `edge-light`],
|
|
166
176
|
[P, `workerd`],
|
|
@@ -177,18 +187,17 @@ I()?.name;
|
|
|
177
187
|
//#endregion
|
|
178
188
|
//#region src/agent.ts
|
|
179
189
|
/**
|
|
180
|
-
* The entry point for AI agent detection
|
|
190
|
+
* The entry point for AI agent detection utilities.
|
|
191
|
+
*
|
|
192
|
+
* Detection is delegated to {@link https://github.com/unjs/std-env | std-env}.
|
|
193
|
+
* The `gunshi/agent` API exposes a stable, minimal profile while the recognized
|
|
194
|
+
* agent names and detection rules may evolve with the upstream detector.
|
|
181
195
|
*
|
|
182
196
|
* @example
|
|
183
197
|
* ```js
|
|
184
198
|
* import { getAgentProfile } from 'gunshi/agent'
|
|
185
199
|
* ```
|
|
186
200
|
*
|
|
187
|
-
* @experimental
|
|
188
|
-
* The `gunshi/agent` entry point is experimental. The agent detection rules
|
|
189
|
-
* are delegated to {@link https://github.com/unjs/std-env | std-env} and may
|
|
190
|
-
* change as the upstream detector list evolves.
|
|
191
|
-
*
|
|
192
201
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
193
202
|
* @license MIT
|
|
194
203
|
*/
|
package/lib/bone.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema, r as ArgValues, u as ArgToken } from "./resolver-
|
|
2
|
-
import { C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, O as ValidationErrorsDecorator, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { i as Args, n as ArgSchema, r as ArgValues, u as ArgToken } from "./resolver-CKLHkuQa.js";
|
|
2
|
+
import { C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, O as ValidationErrorsDecorator, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-8Qh1S2q6.js";
|
|
3
3
|
|
|
4
4
|
//#region src/cli/bone.d.ts
|
|
5
5
|
/**
|
package/lib/bone.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as hasPriorityValidationError } from "./error-
|
|
2
|
-
import { t as plugin } from "./plugin-
|
|
3
|
-
import { a as namespacedId, o as COMMON_ARGS, t as renderer } from "./src-
|
|
4
|
-
import { t as cliCore } from "./core-
|
|
1
|
+
import { r as hasPriorityValidationError } from "./error-BxeGn0JU.js";
|
|
2
|
+
import { t as plugin } from "./plugin-BY44BdcY.js";
|
|
3
|
+
import { a as namespacedId, o as COMMON_ARGS, t as renderer } from "./src-a-JpaUM5.js";
|
|
4
|
+
import { t as cliCore } from "./core-vmpEqkpT.js";
|
|
5
5
|
//#region ../plugin-global/src/types.ts
|
|
6
6
|
/**
|
|
7
7
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
package/lib/combinators.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema } from "./resolver-
|
|
1
|
+
import { i as Args, n as ArgSchema } from "./resolver-CKLHkuQa.js";
|
|
2
2
|
|
|
3
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.28.
|
|
3
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.28.1/node_modules/args-tokens/lib/combinators.d.ts
|
|
4
4
|
|
|
5
5
|
//#region src/combinators.d.ts
|
|
6
6
|
/**
|
package/lib/combinators.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as formatChoices } from "./utils-
|
|
2
|
-
import { n as ArgsValidationErrorKeys, t as ArgsValidationError } from "./resolver-
|
|
3
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.28.
|
|
1
|
+
import { t as formatChoices } from "./utils-CfOBA5zn.js";
|
|
2
|
+
import { n as ArgsValidationErrorKeys, t as ArgsValidationError } from "./resolver-UjEQwV-U.js";
|
|
3
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.28.1/node_modules/args-tokens/lib/combinators.js
|
|
4
4
|
/**
|
|
5
5
|
* Parser combinator factory functions for composable argument schema construction.
|
|
6
6
|
*
|
package/lib/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as Args, r as ArgValues, u as ArgToken } from "./resolver-
|
|
2
|
-
import { _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, m as DefaultGunshiParams, n as CliOptions, r as Command, s as CommandContextExtension, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { i as Args, r as ArgValues, u as ArgToken } from "./resolver-CKLHkuQa.js";
|
|
2
|
+
import { _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, m as DefaultGunshiParams, n as CliOptions, r as Command, s as CommandContextExtension, x as LazyCommand, y as GunshiParams } from "./types-8Qh1S2q6.js";
|
|
3
3
|
|
|
4
4
|
//#region src/context.d.ts
|
|
5
5
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as NOOP, r as CLI_OPTIONS_DEFAULT, t as createCommandContext } from "./context-CAPhwgJJ.js";
|
|
2
|
-
import { n as kebabnize } from "./utils-
|
|
2
|
+
import { n as kebabnize } from "./utils-CfOBA5zn.js";
|
|
3
3
|
import { create, getCommandSubCommands, isLazyCommand, resolveLazyCommand } from "./utils.js";
|
|
4
|
-
import { a as parseArgs, i as resolveArgs, n as ArgsValidationErrorKeys, t as ArgsValidationError } from "./resolver-
|
|
5
|
-
import { n as CommandNotFoundErrorKeys, r as hasPriorityValidationError, t as CommandNotFoundError } from "./error-
|
|
4
|
+
import { a as parseArgs, i as resolveArgs, n as ArgsValidationErrorKeys, t as ArgsValidationError } from "./resolver-UjEQwV-U.js";
|
|
5
|
+
import { n as CommandNotFoundErrorKeys, r as hasPriorityValidationError, t as CommandNotFoundError } from "./error-BxeGn0JU.js";
|
|
6
6
|
//#region src/decorators.ts
|
|
7
7
|
/**
|
|
8
8
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
package/lib/definition.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema, r as ArgValues } from "./resolver-
|
|
2
|
-
import { C as NormalizeToGunshiParams, _ as ExtractArgs, b as GunshiParamsConstraint, d as CommandLoader, f as CommandRunner, h as ExtendContext, m as DefaultGunshiParams, r as Command, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { i as Args, n as ArgSchema, r as ArgValues } from "./resolver-CKLHkuQa.js";
|
|
2
|
+
import { C as NormalizeToGunshiParams, _ as ExtractArgs, b as GunshiParamsConstraint, d as CommandLoader, f as CommandRunner, h as ExtendContext, m as DefaultGunshiParams, r as Command, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-8Qh1S2q6.js";
|
|
3
3
|
import { CommandContextParams, createCommandContext } from "./context.js";
|
|
4
4
|
|
|
5
5
|
//#region src/definition.d.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as ArgsValidationErrorKeys, r as isArgsValidationError } from "./resolver-
|
|
2
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.28.
|
|
1
|
+
import { n as ArgsValidationErrorKeys, r as isArgsValidationError } from "./resolver-UjEQwV-U.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.28.1/node_modules/args-tokens/lib/index.js
|
|
3
3
|
/**
|
|
4
4
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
5
5
|
* @license MIT
|
package/lib/generator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, n as CliOptions, r as Command, x as LazyCommand } from "./types-
|
|
1
|
+
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, n as CliOptions, r as Command, x as LazyCommand } from "./types-8Qh1S2q6.js";
|
|
2
2
|
|
|
3
3
|
//#region src/generator.d.ts
|
|
4
4
|
|
package/lib/generator.js
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as ArgsValidationError, c as isArgsValidationError, d as parseArgs, i as Args, l as resolveArgs, n as ArgSchema, o as ArgsValidationErrorCode, r as ArgValues, s as ArgsValidationErrorKeys, u as ArgToken } from "./resolver-
|
|
2
|
-
import { A as Plugin, C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, F as PluginWithExtension, I as PluginWithoutExtension, L as plugin, M as PluginExtension, N as PluginFunction, O as ValidationErrorsDecorator, P as PluginOptions, R as PluginContext, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, j as PluginDependency, k as OnPluginExtension, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { a as ArgsValidationError, c as isArgsValidationError, d as parseArgs, i as Args, l as resolveArgs, n as ArgSchema, o as ArgsValidationErrorCode, r as ArgValues, s as ArgsValidationErrorKeys, u as ArgToken } from "./resolver-CKLHkuQa.js";
|
|
2
|
+
import { A as Plugin, C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, F as PluginWithExtension, I as PluginWithoutExtension, L as plugin, M as PluginExtension, N as PluginFunction, O as ValidationErrorsDecorator, P as PluginOptions, R as PluginContext, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, j as PluginDependency, k as OnPluginExtension, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-8Qh1S2q6.js";
|
|
3
3
|
import { CommandContextParams, createCommandContext } from "./context.js";
|
|
4
4
|
import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition.js";
|
|
5
|
-
import { a as hasPriorityValidationError, i as CommandNotFoundErrorOptions, n as CommandNotFoundErrorCode, o as isCommandNotFoundError, r as CommandNotFoundErrorKeys, s as ANONYMOUS_COMMAND_NAME, t as CommandNotFoundError } from "./error-
|
|
5
|
+
import { a as hasPriorityValidationError, i as CommandNotFoundErrorOptions, n as CommandNotFoundErrorCode, o as isCommandNotFoundError, r as CommandNotFoundErrorKeys, s as ANONYMOUS_COMMAND_NAME, t as CommandNotFoundError } from "./error-DdRv50OI.js";
|
|
6
6
|
|
|
7
7
|
//#region ../plugin-i18n/src/types.d.ts
|
|
8
8
|
/**
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as ANONYMOUS_COMMAND_NAME, t as createCommandContext } from "./context-CAPhwgJJ.js";
|
|
2
|
-
import { a as parseArgs, i as resolveArgs, n as ArgsValidationErrorKeys, r as isArgsValidationError, t as ArgsValidationError } from "./resolver-
|
|
3
|
-
import { i as isCommandNotFoundError, n as CommandNotFoundErrorKeys, r as hasPriorityValidationError, t as CommandNotFoundError } from "./error-
|
|
4
|
-
import { t as plugin } from "./plugin-
|
|
5
|
-
import { a as namespacedId } from "./src-
|
|
6
|
-
import { t as cli } from "./cli-
|
|
2
|
+
import { a as parseArgs, i as resolveArgs, n as ArgsValidationErrorKeys, r as isArgsValidationError, t as ArgsValidationError } from "./resolver-UjEQwV-U.js";
|
|
3
|
+
import { i as isCommandNotFoundError, n as CommandNotFoundErrorKeys, r as hasPriorityValidationError, t as CommandNotFoundError } from "./error-BxeGn0JU.js";
|
|
4
|
+
import { t as plugin } from "./plugin-BY44BdcY.js";
|
|
5
|
+
import { a as namespacedId } from "./src-a-JpaUM5.js";
|
|
6
|
+
import { t as cli } from "./cli-8lpU57Wl.js";
|
|
7
7
|
import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition.js";
|
|
8
8
|
//#region ../plugin-i18n/src/translation.ts
|
|
9
9
|
/**
|
package/lib/plugin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as ArgsValidationError, c as isArgsValidationError, i as Args, n as ArgSchema, o as ArgsValidationErrorCode, r as ArgValues, s as ArgsValidationErrorKeys, u as ArgToken } from "./resolver-
|
|
2
|
-
import { A as Plugin, C as NormalizeToGunshiParams, F as PluginWithExtension, I as PluginWithoutExtension, L as plugin, M as PluginExtension, N as PluginFunction, O as ValidationErrorsDecorator, P as PluginOptions, R as PluginContext, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, f as CommandRunner, h as ExtendContext, j as PluginDependency, k as OnPluginExtension, m as DefaultGunshiParams, o as CommandContextCore, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { a as ArgsValidationError, c as isArgsValidationError, i as Args, n as ArgSchema, o as ArgsValidationErrorCode, r as ArgValues, s as ArgsValidationErrorKeys, u as ArgToken } from "./resolver-CKLHkuQa.js";
|
|
2
|
+
import { A as Plugin, C as NormalizeToGunshiParams, F as PluginWithExtension, I as PluginWithoutExtension, L as plugin, M as PluginExtension, N as PluginFunction, O as ValidationErrorsDecorator, P as PluginOptions, R as PluginContext, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, f as CommandRunner, h as ExtendContext, j as PluginDependency, k as OnPluginExtension, m as DefaultGunshiParams, o as CommandContextCore, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-8Qh1S2q6.js";
|
|
3
3
|
import { CommandContextParams, createCommandContext } from "./context.js";
|
|
4
|
-
import { a as hasPriorityValidationError, c as CLI_OPTIONS_DEFAULT, i as CommandNotFoundErrorOptions, n as CommandNotFoundErrorCode, o as isCommandNotFoundError, r as CommandNotFoundErrorKeys, s as ANONYMOUS_COMMAND_NAME, t as CommandNotFoundError } from "./error-
|
|
4
|
+
import { a as hasPriorityValidationError, c as CLI_OPTIONS_DEFAULT, i as CommandNotFoundErrorOptions, n as CommandNotFoundErrorCode, o as isCommandNotFoundError, r as CommandNotFoundErrorKeys, s as ANONYMOUS_COMMAND_NAME, t as CommandNotFoundError } from "./error-DdRv50OI.js";
|
|
5
5
|
|
|
6
6
|
//#region src/plugin.d.ts
|
|
7
7
|
/**
|
package/lib/plugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as ANONYMOUS_COMMAND_NAME, r as CLI_OPTIONS_DEFAULT, t as createCommandContext } from "./context-CAPhwgJJ.js";
|
|
2
|
-
import { n as ArgsValidationErrorKeys, r as isArgsValidationError, t as ArgsValidationError } from "./resolver-
|
|
3
|
-
import { i as isCommandNotFoundError, n as CommandNotFoundErrorKeys, r as hasPriorityValidationError, t as CommandNotFoundError } from "./error-
|
|
4
|
-
import { t as plugin } from "./plugin-
|
|
2
|
+
import { n as ArgsValidationErrorKeys, r as isArgsValidationError, t as ArgsValidationError } from "./resolver-UjEQwV-U.js";
|
|
3
|
+
import { i as isCommandNotFoundError, n as CommandNotFoundErrorKeys, r as hasPriorityValidationError, t as CommandNotFoundError } from "./error-BxeGn0JU.js";
|
|
4
|
+
import { t as plugin } from "./plugin-BY44BdcY.js";
|
|
5
5
|
export { ANONYMOUS_COMMAND_NAME, ArgsValidationError, ArgsValidationErrorKeys, CLI_OPTIONS_DEFAULT, CommandNotFoundError, CommandNotFoundErrorKeys, createCommandContext, hasPriorityValidationError, isArgsValidationError, isCommandNotFoundError, plugin };
|
package/lib/renderer.d.ts
CHANGED
package/lib/renderer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as renderHeader, n as renderValidationErrors, r as renderUsage } from "./src-
|
|
1
|
+
import { i as renderHeader, n as renderValidationErrors, r as renderUsage } from "./src-a-JpaUM5.js";
|
|
2
2
|
//#region src/renderer.ts
|
|
3
3
|
/**
|
|
4
4
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.28.
|
|
1
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.28.1/node_modules/args-tokens/lib/parser-DT7Ztcch.d.ts
|
|
2
2
|
//#region src/parser.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Entry point of argument parser.
|
|
@@ -88,7 +88,7 @@ declare function parseArgs(args: string[], options?: ParserOptions): ArgToken[];
|
|
|
88
88
|
* @returns Whether `arg` is a short option.
|
|
89
89
|
*/
|
|
90
90
|
//#endregion
|
|
91
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.28.
|
|
91
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.28.1/node_modules/args-tokens/lib/resolver.d.ts
|
|
92
92
|
//#region src/resolver.d.ts
|
|
93
93
|
/**
|
|
94
94
|
* An argument schema definition for command-line argument parsing.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as kebabnize, t as formatChoices } from "./utils-
|
|
2
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.28.
|
|
1
|
+
import { n as kebabnize, t as formatChoices } from "./utils-CfOBA5zn.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.28.1/node_modules/args-tokens/lib/parser.js
|
|
3
3
|
/**
|
|
4
4
|
* forked from `nodejs/node` (`pkgjs/parseargs`)
|
|
5
5
|
* repository url: https://github.com/nodejs/node (https://github.com/pkgjs/parseargs)
|
|
@@ -204,7 +204,7 @@ function hasOptionValue(value) {
|
|
|
204
204
|
return !(value == null) && value.codePointAt(0) !== HYPHEN_CODE;
|
|
205
205
|
}
|
|
206
206
|
//#endregion
|
|
207
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.28.
|
|
207
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.28.1/node_modules/args-tokens/lib/resolver.js
|
|
208
208
|
/**
|
|
209
209
|
* Entry point of argument options resolver.
|
|
210
210
|
*
|
|
@@ -306,9 +306,17 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
|
|
|
306
306
|
const rest = [];
|
|
307
307
|
const optionTokens = [];
|
|
308
308
|
const positionalTokens = [];
|
|
309
|
+
const argEntries = Object.entries(args);
|
|
309
310
|
let currentLongOption;
|
|
310
311
|
let currentShortOption;
|
|
311
312
|
const expandableShortOptions = [];
|
|
313
|
+
function getOptionName(rawArg, schema) {
|
|
314
|
+
return toKebab || schema.toKebab ? kebabnize(rawArg) : rawArg;
|
|
315
|
+
}
|
|
316
|
+
function checkLongTokenName(option, schema, token) {
|
|
317
|
+
if (token.rawName == void 0 || !hasLongOptionPrefix(token.rawName)) return false;
|
|
318
|
+
return token.name === option || schema.type === "boolean" && schema.negatable === true && token.name === `no-${option}`;
|
|
319
|
+
}
|
|
312
320
|
function toShortValue() {
|
|
313
321
|
if (expandableShortOptions.length === 0) return;
|
|
314
322
|
else {
|
|
@@ -336,6 +344,13 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
|
|
|
336
344
|
* separate tokens into positionals, long and short options, after that resolve values
|
|
337
345
|
*/
|
|
338
346
|
const schemas = Object.values(args);
|
|
347
|
+
const booleanLongOptionNames = /* @__PURE__ */ new Set();
|
|
348
|
+
for (const [rawArg, schema] of Object.entries(args)) {
|
|
349
|
+
if (schema.type !== "boolean") continue;
|
|
350
|
+
const arg = toKebab || schema.toKebab ? kebabnize(rawArg) : rawArg;
|
|
351
|
+
booleanLongOptionNames.add(arg);
|
|
352
|
+
if (schema.negatable === true) booleanLongOptionNames.add(`no-${arg}`);
|
|
353
|
+
}
|
|
339
354
|
let terminated = false;
|
|
340
355
|
for (let i = 0; i < tokens.length; i++) {
|
|
341
356
|
const token = tokens[i];
|
|
@@ -348,7 +363,7 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
|
|
|
348
363
|
positionalTokens.push({ ...token });
|
|
349
364
|
applyShortOptionValue();
|
|
350
365
|
} else applyShortOptionValue(token.value);
|
|
351
|
-
else if (currentLongOption) if (
|
|
366
|
+
else if (currentLongOption) if (booleanLongOptionNames.has(currentLongOption.name)) {
|
|
352
367
|
positionalTokens.push({ ...token });
|
|
353
368
|
applyLongOptionValue();
|
|
354
369
|
} else applyLongOptionValue(token.value);
|
|
@@ -401,11 +416,7 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
|
|
|
401
416
|
const errors = [];
|
|
402
417
|
const explicit = Object.create(null);
|
|
403
418
|
const actualInputNames = /* @__PURE__ */ new Map();
|
|
404
|
-
const argEntries = Object.entries(args);
|
|
405
419
|
let requiredPositionalsAfter;
|
|
406
|
-
function checkTokenName(option, schema, token) {
|
|
407
|
-
return token.name === (schema.type === "boolean" ? schema.negatable && token.name?.startsWith("no-") ? `no-${option}` : option : option);
|
|
408
|
-
}
|
|
409
420
|
const positionalItemCount = tokens.filter((token) => token.kind === "positional").length;
|
|
410
421
|
function getPositionalSkipIndex() {
|
|
411
422
|
return Math.min(skipPositionalIndex, positionalItemCount);
|
|
@@ -416,7 +427,7 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
|
|
|
416
427
|
}
|
|
417
428
|
let positionalsCount = 0;
|
|
418
429
|
for (const [rawArg, schema] of argEntries) {
|
|
419
|
-
const arg =
|
|
430
|
+
const arg = getOptionName(rawArg, schema);
|
|
420
431
|
explicit[rawArg] = false;
|
|
421
432
|
if (schema.type === "positional") {
|
|
422
433
|
if (skipPositionalIndex > SKIP_POSITIONAL_DEFAULT) while (positionalsCount <= getPositionalSkipIndex()) positionalsCount++;
|
|
@@ -470,7 +481,7 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
|
|
|
470
481
|
}
|
|
471
482
|
if (schema.required) {
|
|
472
483
|
if (!optionTokens.find((token) => {
|
|
473
|
-
return schema.short && token.name === schema.short
|
|
484
|
+
return schema.short && token.name === schema.short && token.rawName != void 0 && isShortOption(token.rawName) || checkLongTokenName(arg, schema, token);
|
|
474
485
|
})) {
|
|
475
486
|
errors.push(createRequireError(rawArg, arg, schema));
|
|
476
487
|
continue;
|
|
@@ -478,14 +489,15 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
|
|
|
478
489
|
}
|
|
479
490
|
for (let i = 0; i < optionTokens.length; i++) {
|
|
480
491
|
const token = optionTokens[i];
|
|
481
|
-
if (
|
|
492
|
+
if (checkLongTokenName(arg, schema, token) || schema.short === token.name && token.rawName != void 0 && isShortOption(token.rawName)) {
|
|
482
493
|
const invalid = validateRequire(token, rawArg, arg, schema);
|
|
483
494
|
if (invalid) {
|
|
484
495
|
errors.push(invalid);
|
|
485
496
|
continue;
|
|
486
497
|
}
|
|
487
498
|
explicit[rawArg] = true;
|
|
488
|
-
const
|
|
499
|
+
const rawName = token.rawName;
|
|
500
|
+
const actualInputName = isShortOption(rawName) ? `-${token.name}` : rawName;
|
|
489
501
|
actualInputNames.set(rawArg, actualInputName);
|
|
490
502
|
const [parsedValue, error] = parse(token, rawArg, arg, schema);
|
|
491
503
|
if (error) errors.push(error);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./context-CAPhwgJJ.js";
|
|
2
|
-
import { n as kebabnize } from "./utils-
|
|
2
|
+
import { n as kebabnize } from "./utils-CfOBA5zn.js";
|
|
3
3
|
import { resolveLazyCommand } from "./utils.js";
|
|
4
|
-
import { n as ArgsValidationErrorKeys, r as isArgsValidationError } from "./resolver-
|
|
5
|
-
import { i as isCommandNotFoundError } from "./error-
|
|
6
|
-
import { t as plugin } from "./plugin-
|
|
4
|
+
import { n as ArgsValidationErrorKeys, r as isArgsValidationError } from "./resolver-UjEQwV-U.js";
|
|
5
|
+
import { i as isCommandNotFoundError } from "./error-BxeGn0JU.js";
|
|
6
|
+
import { t as plugin } from "./plugin-BY44BdcY.js";
|
|
7
7
|
/**
|
|
8
8
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
9
9
|
* @license MIT
|
|
@@ -29,7 +29,6 @@ const COMMON_ARGS = {
|
|
|
29
29
|
};
|
|
30
30
|
//#endregion
|
|
31
31
|
//#region ../resources/locales/en-US.json
|
|
32
|
-
var NEGATABLE = "Negatable of";
|
|
33
32
|
var en_US_default = {
|
|
34
33
|
COMMAND: "COMMAND",
|
|
35
34
|
COMMANDS: "COMMANDS",
|
|
@@ -39,7 +38,7 @@ var en_US_default = {
|
|
|
39
38
|
OPTIONS: "OPTIONS",
|
|
40
39
|
EXAMPLES: "EXAMPLES",
|
|
41
40
|
FORMORE: "For more info, run any command with the `--help` flag",
|
|
42
|
-
NEGATABLE,
|
|
41
|
+
NEGATABLE: "Negatable of",
|
|
43
42
|
DEFAULT: "default",
|
|
44
43
|
CHOICES: "choices",
|
|
45
44
|
help: "Display this help message",
|
|
@@ -172,7 +171,7 @@ function localizable(ctx, cmd, translate) {
|
|
|
172
171
|
}
|
|
173
172
|
const schema = ctx.args[argKey];
|
|
174
173
|
if (!schema) return argKey;
|
|
175
|
-
return negatable && schema.type === "boolean" && schema.negatable ? `${NEGATABLE} ${makeShortLongOptionPair(schema, argKey, ctx.toKebab)}` : schema.description || "";
|
|
174
|
+
return negatable && schema.type === "boolean" && schema.negatable ? `${en_US_default["NEGATABLE"]} ${makeShortLongOptionPair(schema, argKey, ctx.toKebab)}` : schema.description || "";
|
|
176
175
|
}
|
|
177
176
|
if (key === resolveKey("description", ctx.name)) return "";
|
|
178
177
|
else if (key === resolveKey("examples", ctx.name)) return await resolveExamples$1(ctx, cmd.examples);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema, r as ArgValues, t as ArgExplicitlyProvided, u as ArgToken } from "./resolver-
|
|
1
|
+
import { i as Args, n as ArgSchema, r as ArgValues, t as ArgExplicitlyProvided, u as ArgToken } from "./resolver-CKLHkuQa.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin/context.d.ts
|
|
4
4
|
/**
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, p as Commandable, r as Command, x as LazyCommand } from "./types-
|
|
1
|
+
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, p as Commandable, r as Command, x as LazyCommand } from "./types-8Qh1S2q6.js";
|
|
2
2
|
|
|
3
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.28.
|
|
3
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.28.1/node_modules/args-tokens/lib/utils.d.ts
|
|
4
4
|
|
|
5
5
|
//#region src/utils.d.ts
|
|
6
6
|
/**
|
package/lib/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gunshi",
|
|
3
3
|
"description": "Modern javascript command-line library",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.37.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"args-tokens": "^0.28.
|
|
111
|
+
"args-tokens": "^0.28.1",
|
|
112
112
|
"deno": "^2.7.14",
|
|
113
113
|
"jsr": "^0.14.3",
|
|
114
114
|
"jsr-exports-lint": "^0.4.2",
|
|
@@ -116,11 +116,11 @@
|
|
|
116
116
|
"std-env": "^4.1.0",
|
|
117
117
|
"tsdown": "0.21.0",
|
|
118
118
|
"zod": "^4.4.3",
|
|
119
|
-
"@gunshi/plugin-
|
|
120
|
-
"@gunshi/plugin-
|
|
121
|
-
"@gunshi/
|
|
122
|
-
"@gunshi/shared": "0.
|
|
123
|
-
"@gunshi/
|
|
119
|
+
"@gunshi/plugin-i18n": "0.37.1",
|
|
120
|
+
"@gunshi/plugin-global": "0.37.1",
|
|
121
|
+
"@gunshi/plugin-renderer": "0.37.1",
|
|
122
|
+
"@gunshi/shared": "0.37.1",
|
|
123
|
+
"@gunshi/resources": "0.37.1"
|
|
124
124
|
},
|
|
125
125
|
"scripts": {
|
|
126
126
|
"build": "tsdown",
|