gunshi 0.24.0 → 0.25.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/lib/{cli-BVD3QITm.js → cli-DVGNVw3h.js} +4 -3
- package/lib/{context-COFfMm-R.js → context-D_EmfRNA.js} +1 -0
- package/lib/context.d.ts +1 -1
- package/lib/context.js +1 -1
- package/lib/{definition-zTfMFgKw.d.ts → definition-CKKX4Yvy.d.ts} +1 -1
- package/lib/{definition-DyVBFqB7.js → definition-wq1Kmbvq.js} +1 -0
- package/lib/definition.d.ts +2 -2
- package/lib/definition.js +1 -1
- package/lib/generator.d.ts +1 -1
- package/lib/generator.js +3 -3
- package/lib/index.d.ts +2 -2
- package/lib/index.js +4 -4
- package/lib/{renderer-kzo45gaB.js → renderer-BzRfaLdJ.js} +17 -9
- package/lib/renderer.d.ts +1 -1
- package/lib/renderer.js +1 -1
- package/lib/{types-BDWiiycu.d.ts → types-DtEE4hKC.d.ts} +11 -0
- package/package.json +7 -80
- package/README.md +0 -142
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ANONYMOUS_COMMAND_NAME, COMMAND_OPTIONS_DEFAULT, COMMON_ARGS, create, isLazyCommand, resolveLazyCommand } from "./utils-D41C8Abf.js";
|
|
2
|
-
import { createCommandContext } from "./context-
|
|
3
|
-
import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-
|
|
2
|
+
import { createCommandContext } from "./context-D_EmfRNA.js";
|
|
3
|
+
import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-BzRfaLdJ.js";
|
|
4
4
|
import { parseArgs, resolveArgs } from "args-tokens";
|
|
5
5
|
|
|
6
6
|
//#region src/cli.ts
|
|
@@ -19,7 +19,8 @@ async function cli(argv, entry, options = {}) {
|
|
|
19
19
|
if (!command) throw new Error(`Command not found: ${name || ""}`);
|
|
20
20
|
const args = resolveArguments(getCommandArgs(command));
|
|
21
21
|
const { values, positionals, rest, error } = resolveArgs(args, tokens, {
|
|
22
|
-
|
|
22
|
+
shortGrouping: true,
|
|
23
|
+
toKebab: command.toKebab,
|
|
23
24
|
skipPositional: cliOptions.subCommands.size > 0 ? 0 : -1
|
|
24
25
|
});
|
|
25
26
|
const omitted = !subCommand;
|
package/lib/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CliOptions, Command, CommandCallMode, CommandContext, LazyCommand } from "./types-
|
|
1
|
+
import { CliOptions, Command, CommandCallMode, CommandContext, LazyCommand } from "./types-DtEE4hKC.js";
|
|
2
2
|
import { ArgToken, ArgValues, Args } from "args-tokens";
|
|
3
3
|
|
|
4
4
|
//#region src/context.d.ts
|
package/lib/context.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Command, CommandLoader, LazyCommand } from "./types-
|
|
1
|
+
import { Command, CommandLoader, LazyCommand } from "./types-DtEE4hKC.js";
|
|
2
2
|
import { ArgSchema, ArgValues as ArgValues$1, Args, Args as Args$1 } from "args-tokens";
|
|
3
3
|
|
|
4
4
|
//#region src/definition.d.ts
|
package/lib/definition.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./types-
|
|
2
|
-
import { ArgSchema, ArgValues, Args, define$1 as define, lazy$1 as lazy } from "./definition-
|
|
1
|
+
import "./types-DtEE4hKC.js";
|
|
2
|
+
import { ArgSchema, ArgValues, Args, define$1 as define, lazy$1 as lazy } from "./definition-CKKX4Yvy.js";
|
|
3
3
|
export { ArgSchema, ArgValues, Args, define, lazy };
|
package/lib/definition.js
CHANGED
package/lib/generator.d.ts
CHANGED
package/lib/generator.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { create } from "./utils-D41C8Abf.js";
|
|
2
|
-
import "./context-
|
|
3
|
-
import "./renderer-
|
|
4
|
-
import { cli } from "./cli-
|
|
2
|
+
import "./context-D_EmfRNA.js";
|
|
3
|
+
import "./renderer-BzRfaLdJ.js";
|
|
4
|
+
import { cli } from "./cli-DVGNVw3h.js";
|
|
5
5
|
|
|
6
6
|
//#region src/generator.ts
|
|
7
7
|
/**
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CliOptions, Command, CommandArgKeys, CommandBuiltinArgsKeys, CommandBuiltinKeys, CommandBuiltinResourceKeys, CommandCallMode, CommandContext, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandResource, CommandResourceFetcher, CommandRunner, Commandable, DEFAULT_LOCALE, GenerateNamespacedKey, KeyOfArgs, LazyCommand, RemovedIndex, TranslationAdapter, TranslationAdapterFactory, TranslationAdapterFactoryOptions } from "./types-
|
|
2
|
-
import { define$1 as define, lazy$1 as lazy } from "./definition-
|
|
1
|
+
import { CliOptions, Command, CommandArgKeys, CommandBuiltinArgsKeys, CommandBuiltinKeys, CommandBuiltinResourceKeys, CommandCallMode, CommandContext, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandResource, CommandResourceFetcher, CommandRunner, Commandable, DEFAULT_LOCALE, GenerateNamespacedKey, KeyOfArgs, LazyCommand, RemovedIndex, TranslationAdapter, TranslationAdapterFactory, TranslationAdapterFactoryOptions } from "./types-DtEE4hKC.js";
|
|
2
|
+
import { define$1 as define, lazy$1 as lazy } from "./definition-CKKX4Yvy.js";
|
|
3
3
|
import { ArgSchema, ArgValues, Args, Args as Args$1, parseArgs, resolveArgs } from "args-tokens";
|
|
4
4
|
|
|
5
5
|
//#region src/cli.d.ts
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_LOCALE$1 as DEFAULT_LOCALE } from "./utils-D41C8Abf.js";
|
|
2
|
-
import { DefaultTranslation } from "./context-
|
|
3
|
-
import { define, lazy } from "./definition-
|
|
4
|
-
import "./renderer-
|
|
5
|
-
import { cli } from "./cli-
|
|
2
|
+
import { DefaultTranslation } from "./context-D_EmfRNA.js";
|
|
3
|
+
import { define, lazy } from "./definition-wq1Kmbvq.js";
|
|
4
|
+
import "./renderer-BzRfaLdJ.js";
|
|
5
|
+
import { cli } from "./cli-DVGNVw3h.js";
|
|
6
6
|
import { parseArgs, resolveArgs } from "args-tokens";
|
|
7
7
|
|
|
8
8
|
export { DEFAULT_LOCALE, DefaultTranslation, cli, define, lazy, parseArgs, resolveArgs };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { COMMON_ARGS, create, resolveArgKey, resolveBuiltInKey, resolveExamples } from "./utils-D41C8Abf.js";
|
|
2
|
+
import { kebabnize } from "args-tokens/utils";
|
|
2
3
|
|
|
3
4
|
//#region src/renderer/header.ts
|
|
4
5
|
/**
|
|
@@ -187,8 +188,9 @@ function hasAllDefaultOptions(ctx) {
|
|
|
187
188
|
function generateOptionsSymbols(ctx) {
|
|
188
189
|
return hasOptionalArgs(ctx) ? hasAllDefaultOptions(ctx) ? `[${ctx.translate(resolveBuiltInKey("OPTIONS"))}]` : `<${ctx.translate(resolveBuiltInKey("OPTIONS"))}>` : "";
|
|
189
190
|
}
|
|
190
|
-
function makeShortLongOptionPair(schema, name) {
|
|
191
|
-
|
|
191
|
+
function makeShortLongOptionPair(schema, name, toKebab) {
|
|
192
|
+
const displayName = toKebab || schema.toKebab ? kebabnize(name) : name;
|
|
193
|
+
let key = `--${displayName}`;
|
|
192
194
|
if (schema.short) key = `-${schema.short}, ${key}`;
|
|
193
195
|
return key;
|
|
194
196
|
}
|
|
@@ -198,12 +200,18 @@ function makeShortLongOptionPair(schema, name) {
|
|
|
198
200
|
* @returns Options pairs for usage
|
|
199
201
|
*/
|
|
200
202
|
function getOptionalArgsPairs(ctx) {
|
|
201
|
-
return Object.entries(ctx.args).reduce((acc, [name,
|
|
202
|
-
if (
|
|
203
|
-
let key = makeShortLongOptionPair(
|
|
204
|
-
if (
|
|
203
|
+
return Object.entries(ctx.args).reduce((acc, [name, schema]) => {
|
|
204
|
+
if (schema.type === "positional") return acc;
|
|
205
|
+
let key = makeShortLongOptionPair(schema, name, ctx.toKebab);
|
|
206
|
+
if (schema.type !== "boolean") {
|
|
207
|
+
const displayName = ctx.toKebab || schema.toKebab ? kebabnize(name) : name;
|
|
208
|
+
key = schema.default ? `${key} [${displayName}]` : `${key} <${displayName}>`;
|
|
209
|
+
}
|
|
205
210
|
acc[name] = key;
|
|
206
|
-
if (
|
|
211
|
+
if (schema.type === "boolean" && schema.negatable && !COMMON_ARGS_KEYS.includes(name)) {
|
|
212
|
+
const displayName = ctx.toKebab || schema.toKebab ? kebabnize(name) : name;
|
|
213
|
+
acc[`no-${name}`] = `--no-${displayName}`;
|
|
214
|
+
}
|
|
207
215
|
return acc;
|
|
208
216
|
}, create());
|
|
209
217
|
}
|
|
@@ -217,7 +225,7 @@ function generateDefaultDisplayValue(ctx, schema) {
|
|
|
217
225
|
function resolveDisplayValue(ctx, key) {
|
|
218
226
|
if (COMMON_ARGS_KEYS.includes(key)) return "";
|
|
219
227
|
const schema = ctx.args[key];
|
|
220
|
-
if ((schema.type === "boolean" || schema.type === "number" || schema.type === "string") && schema.default !== void 0) return `(${generateDefaultDisplayValue(ctx, schema)})`;
|
|
228
|
+
if ((schema.type === "boolean" || schema.type === "number" || schema.type === "string" || schema.type === "custom") && schema.default !== void 0) return `(${generateDefaultDisplayValue(ctx, schema)})`;
|
|
221
229
|
if (schema.type === "enum") {
|
|
222
230
|
const _default = schema.default !== void 0 ? generateDefaultDisplayValue(ctx, schema) : "";
|
|
223
231
|
const choices = `${ctx.translate(resolveBuiltInKey("CHOICES"))}: ${schema.choices.join(" | ")}`;
|
|
@@ -239,7 +247,7 @@ async function generateOptionalArgsUsage(ctx, optionsPairs) {
|
|
|
239
247
|
if (!rawDesc && key.startsWith("no-")) {
|
|
240
248
|
const name = resolveNegatableKey(key);
|
|
241
249
|
const schema = ctx.args[name];
|
|
242
|
-
const optionKey = makeShortLongOptionPair(schema, name);
|
|
250
|
+
const optionKey = makeShortLongOptionPair(schema, name, ctx.toKebab);
|
|
243
251
|
rawDesc = `${ctx.translate(resolveBuiltInKey("NEGATABLE"))} ${optionKey}`;
|
|
244
252
|
}
|
|
245
253
|
const optionsSchema = ctx.env.usageOptionType ? `[${resolveNegatableType(key, ctx)}] ` : "";
|
package/lib/renderer.d.ts
CHANGED
package/lib/renderer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import "./utils-D41C8Abf.js";
|
|
2
|
-
import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-
|
|
2
|
+
import { renderHeader, renderUsage, renderValidationErrors } from "./renderer-BzRfaLdJ.js";
|
|
3
3
|
|
|
4
4
|
export { renderHeader, renderUsage, renderValidationErrors };
|
|
@@ -271,11 +271,17 @@ interface CommandContext<A extends Args = Args, V = ArgValues<A>> {
|
|
|
271
271
|
* 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.
|
|
272
272
|
*/
|
|
273
273
|
callMode: CommandCallMode;
|
|
274
|
+
/**
|
|
275
|
+
* Whether to convert the camel-case style argument name to kebab-case.
|
|
276
|
+
* This context value is set from {@link Command.toKebab} option.
|
|
277
|
+
*/
|
|
278
|
+
toKebab?: boolean;
|
|
274
279
|
/**
|
|
275
280
|
* Output a message.
|
|
276
281
|
* If {@link CommandEnvironment.usageSilent} is true, the message is not output.
|
|
277
282
|
* @param message an output message, @see {@link console.log}
|
|
278
283
|
* @param optionalParams an optional parameters, @see {@link console.log}
|
|
284
|
+
* @internal
|
|
279
285
|
*/
|
|
280
286
|
log: (message?: any, ...optionalParams: any[]) => void;
|
|
281
287
|
/**
|
|
@@ -324,6 +330,11 @@ interface Command<A extends Args = Args> {
|
|
|
324
330
|
* Command resource fetcher.
|
|
325
331
|
*/
|
|
326
332
|
resource?: CommandResourceFetcher<A>;
|
|
333
|
+
/**
|
|
334
|
+
* Whether to convert the camel-case style argument name to kebab-case.
|
|
335
|
+
* If you will set to `true`, All {@link Command.args} names will be converted to kebab-case.
|
|
336
|
+
*/
|
|
337
|
+
toKebab?: boolean;
|
|
327
338
|
}
|
|
328
339
|
/**
|
|
329
340
|
* Command resource.
|
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.25.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/kazupon/gunshi.git"
|
|
16
|
+
"url": "git+https://github.com/kazupon/gunshi.git",
|
|
17
|
+
"directory": "packages/gunshi"
|
|
17
18
|
},
|
|
18
19
|
"keywords": [
|
|
19
20
|
"command",
|
|
@@ -78,95 +79,21 @@
|
|
|
78
79
|
}
|
|
79
80
|
},
|
|
80
81
|
"dependencies": {
|
|
81
|
-
"args-tokens": "^0.
|
|
82
|
+
"args-tokens": "^0.20.1"
|
|
82
83
|
},
|
|
83
84
|
"devDependencies": {
|
|
84
|
-
"@eslint/markdown": "^6.4.0",
|
|
85
85
|
"@intlify/core": "next",
|
|
86
|
-
"@kazupon/eslint-config": "^0.29.0",
|
|
87
|
-
"@kazupon/prettier-config": "^0.1.1",
|
|
88
|
-
"@types/node": "^22.15.21",
|
|
89
|
-
"@typescript/native-preview": "7.0.0-dev.20250522.2",
|
|
90
|
-
"@vitest/eslint-plugin": "^1.2.0",
|
|
91
|
-
"bumpp": "^10.1.1",
|
|
92
86
|
"deno": "^2.3.3",
|
|
93
|
-
"eslint": "^9.27.0",
|
|
94
|
-
"eslint-config-prettier": "^10.1.5",
|
|
95
|
-
"eslint-import-resolver-typescript": "^4.3.5",
|
|
96
|
-
"eslint-plugin-import": "^2.31.0",
|
|
97
|
-
"eslint-plugin-jsonc": "^2.20.1",
|
|
98
|
-
"eslint-plugin-module-interop": "^0.3.1",
|
|
99
|
-
"eslint-plugin-promise": "^7.2.1",
|
|
100
|
-
"eslint-plugin-regexp": "^2.7.0",
|
|
101
|
-
"eslint-plugin-unicorn": "^58.0.0",
|
|
102
|
-
"eslint-plugin-unused-imports": "^4.1.4",
|
|
103
|
-
"eslint-plugin-vue": "^10.1.0",
|
|
104
|
-
"eslint-plugin-vue-composable": "^1.0.0",
|
|
105
|
-
"eslint-plugin-yml": "^1.18.0",
|
|
106
|
-
"gh-changelogen": "^0.2.8",
|
|
107
|
-
"gunshi019": "npm:gunshi@0.23.1",
|
|
108
87
|
"jsr": "^0.13.4",
|
|
109
88
|
"jsr-exports-lint": "^0.4.0",
|
|
110
|
-
"knip": "^5.57.2",
|
|
111
|
-
"lint-staged": "^16.0.0",
|
|
112
89
|
"messageformat": "4.0.0-12",
|
|
113
|
-
"mitata": "^1.0.34",
|
|
114
|
-
"pkg-pr-new": "^0.0.50",
|
|
115
|
-
"prettier": "^3.5.3",
|
|
116
90
|
"publint": "^0.3.12",
|
|
117
|
-
"tsdown": "^0.12.
|
|
118
|
-
"
|
|
119
|
-
"typedoc-plugin-markdown": "^4.6.3",
|
|
120
|
-
"typedoc-vitepress-theme": "^1.1.2",
|
|
121
|
-
"typescript-eslint": "^8.32.1",
|
|
122
|
-
"vitepress": "^1.6.3",
|
|
123
|
-
"vitepress-plugin-group-icons": "^1.5.5",
|
|
124
|
-
"vitepress-plugin-llms": "^1.3.3",
|
|
125
|
-
"vitest": "^3.1.4",
|
|
126
|
-
"vue": "^3.5.14"
|
|
127
|
-
},
|
|
128
|
-
"prettier": "@kazupon/prettier-config",
|
|
129
|
-
"lint-staged": {
|
|
130
|
-
"*.ts?(x)": [
|
|
131
|
-
"prettier --parser=typescript --write",
|
|
132
|
-
"eslint --fix"
|
|
133
|
-
],
|
|
134
|
-
"*.{js,mjs,cjs}": [
|
|
135
|
-
"prettier --write",
|
|
136
|
-
"eslint --fix"
|
|
137
|
-
],
|
|
138
|
-
"*.{json,jsonc,json5,md,yml,yaml}": [
|
|
139
|
-
"prettier --write"
|
|
140
|
-
]
|
|
91
|
+
"tsdown": "^0.12.3",
|
|
92
|
+
"zod": "^3.25.28"
|
|
141
93
|
},
|
|
142
94
|
"scripts": {
|
|
143
|
-
"bench:mitata": "node --expose-gc bench/mitata.js",
|
|
144
|
-
"bench:vitest": "vitest bench --run",
|
|
145
95
|
"build": "tsdown",
|
|
146
|
-
"changelog": "gh-changelogen --repo=kazupon/gunshi",
|
|
147
|
-
"clean": "git clean -df",
|
|
148
|
-
"dev": "pnpx @eslint/config-inspector --config eslint.config.ts",
|
|
149
|
-
"dev:eslint": "pnpx @eslint/config-inspector --config eslint.config.ts",
|
|
150
|
-
"dev:typedoc": "typedoc --watch --preserveWatchOutput",
|
|
151
|
-
"docs:build": "pnpm run docs:build:typedoc && pnpm docs:build:vitepress",
|
|
152
|
-
"docs:build:typedoc": "typedoc --excludeInternal",
|
|
153
|
-
"docs:build:vitepress": "vitepress build docs",
|
|
154
|
-
"docs:dev": "pnpm run docs:build:typedoc && pnpm docs:dev:vitepress",
|
|
155
|
-
"docs:dev:vitepress": "vitepress dev docs",
|
|
156
|
-
"docs:preview": "vitepress preview docs",
|
|
157
|
-
"fix": "pnpm run --stream --color \"/^fix:/\"",
|
|
158
|
-
"fix:eslint": "eslint . --fix",
|
|
159
|
-
"fix:knip": "knip --fix --no-exit-code",
|
|
160
|
-
"fix:prettier": "prettier . --write",
|
|
161
|
-
"lint": "pnpm run --stream --color \"/^lint:/\"",
|
|
162
|
-
"lint:eslint": "eslint .",
|
|
163
96
|
"lint:jsr": "jsr publish --dry-run --allow-dirty",
|
|
164
|
-
"
|
|
165
|
-
"lint:prettier": "prettier . --check",
|
|
166
|
-
"release": "bumpp --commit \"release: v%s\" --all --push --tag",
|
|
167
|
-
"test": "vitest --typecheck run",
|
|
168
|
-
"typecheck": "pnpm run --stream --color \"/^typecheck:/\"",
|
|
169
|
-
"typecheck:deno": "deno check --all ./src",
|
|
170
|
-
"typecheck:tsc": "tsgo --noEmit"
|
|
97
|
+
"typecheck:deno": "deno check --all ./src"
|
|
171
98
|
}
|
|
172
99
|
}
|
package/README.md
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img width="196" src="./assets/logo.png">
|
|
3
|
-
</p>
|
|
4
|
-
<h1 align="center">🏯 Gunshi</h1>
|
|
5
|
-
|
|
6
|
-
[![Version][npm-version-src]][npm-version-href]
|
|
7
|
-
[![CI][ci-src]][ci-href]
|
|
8
|
-
[![InstallSize][install-size-src]][install-size-src]
|
|
9
|
-
[![JSR][jsr-src]][jsr-href]
|
|
10
|
-
|
|
11
|
-
Gunshi is a modern javascript command-line library
|
|
12
|
-
|
|
13
|
-
<!-- eslint-disable markdown/no-missing-label-refs -->
|
|
14
|
-
|
|
15
|
-
> [!TIP]
|
|
16
|
-
> gunshi (軍師) is a position in ancient Japanese samurai battle in which a samurai devised strategies and gave orders. That name is inspired by the word "command".
|
|
17
|
-
|
|
18
|
-
<!-- eslint-enable markdown/no-missing-label-refs -->
|
|
19
|
-
|
|
20
|
-
## ✨ Features
|
|
21
|
-
|
|
22
|
-
Gunshi is designed to simplify the creation of modern command-line interfaces:
|
|
23
|
-
|
|
24
|
-
- 📏 **Simple & Universal**: Run the commands with simple API and support universal runtime.
|
|
25
|
-
- ⚙️ **Declarative configuration**: Configure command modules declaratively for better organization and maintainability.
|
|
26
|
-
- 🛡️ **Type Safe**: TypeScript support with type-safe argument parsing and option resolution by [args-tokens](https://github.com/kazupon/args-tokens)
|
|
27
|
-
- 🧩 **Composable**: Create modular sub-commands that can be composed together for complex CLIs.
|
|
28
|
-
- ⏳ **Lazy & Async**: Load command modules lazily and execute them asynchronously for better performance.
|
|
29
|
-
- 📜 **Auto usage generation**: Generate helpful usage messages automatically for your commands.
|
|
30
|
-
- 🎨 **Custom usage generation**: Customize how usage messages are generated to match your CLI's style.
|
|
31
|
-
- 🌍 **Internationalization**: Support multiple languages with built-in i18n, locale resource lazy loading and i18n library integration.
|
|
32
|
-
|
|
33
|
-
## 💿 Installation
|
|
34
|
-
|
|
35
|
-
```sh
|
|
36
|
-
# npm
|
|
37
|
-
npm install --save gunshi
|
|
38
|
-
|
|
39
|
-
## pnpm
|
|
40
|
-
pnpm add gunshi
|
|
41
|
-
|
|
42
|
-
## yarn
|
|
43
|
-
yarn add gunshi
|
|
44
|
-
|
|
45
|
-
## deno
|
|
46
|
-
deno add jsr:@kazupon/gunshi
|
|
47
|
-
|
|
48
|
-
## bun
|
|
49
|
-
bun add gunshi
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## 🚀 Usage
|
|
53
|
-
|
|
54
|
-
```js
|
|
55
|
-
import { cli } from 'gunshi'
|
|
56
|
-
|
|
57
|
-
// define a command with declarative configuration, using commandable object
|
|
58
|
-
const command = {
|
|
59
|
-
name: 'greet',
|
|
60
|
-
description: 'A greeting command',
|
|
61
|
-
options: {
|
|
62
|
-
name: {
|
|
63
|
-
type: 'string',
|
|
64
|
-
short: 'n',
|
|
65
|
-
description: 'Name to greet'
|
|
66
|
-
},
|
|
67
|
-
greeting: {
|
|
68
|
-
type: 'string',
|
|
69
|
-
short: 'g',
|
|
70
|
-
default: 'Hello',
|
|
71
|
-
description: 'Greeting to use (default: "Hello")'
|
|
72
|
-
},
|
|
73
|
-
times: {
|
|
74
|
-
type: 'number',
|
|
75
|
-
short: 't',
|
|
76
|
-
default: 1,
|
|
77
|
-
description: 'Number of times to repeat the greeting (default: 1)'
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
run: ctx => {
|
|
81
|
-
const { name = 'World', greeting, times } = ctx.values
|
|
82
|
-
for (let i = 0; i < times; i++) {
|
|
83
|
-
console.log(`${greeting}, ${name}!`)
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// run a command that is defined above
|
|
89
|
-
// (the 3rd argument of `cli` is the command option)
|
|
90
|
-
await cli(process.argv.slice(2), command, {
|
|
91
|
-
name: 'my-app',
|
|
92
|
-
version: '1.0.0',
|
|
93
|
-
description: 'My CLI application'
|
|
94
|
-
})
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
About more details and usage, see [documentations](https://gunshi.dev)
|
|
98
|
-
|
|
99
|
-
## 💁♀️ Showcases
|
|
100
|
-
|
|
101
|
-
- [pnpmc](https://github.com/kazupon/pnpmc): PNPM Catalogs Tooling
|
|
102
|
-
- [sourcemap-publisher](https://github.com/es-tooling/sourcemap-publisher): A tool to publish sourcemaps externally and rewrite sourcemap URLs at pre-publish time
|
|
103
|
-
- [curxy](https://github.com/ryoppippi/curxy): An proxy worker for using ollama in cursor
|
|
104
|
-
|
|
105
|
-
## 🙌 Contributing guidelines
|
|
106
|
-
|
|
107
|
-
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.
|
|
108
|
-
|
|
109
|
-
## 💖 Credits
|
|
110
|
-
|
|
111
|
-
This project is inspired and powered by:
|
|
112
|
-
|
|
113
|
-
- [`citty`](https://github.com/unjs/citty), created by [UnJS team](https://github.com/unjs) and contributors
|
|
114
|
-
- [`ordana`](https://github.com/sapphi-red/ordana), createdy by [sapphi-red](https://github.com/sapphi-red), inspired documentation generation
|
|
115
|
-
- cline and claude 3.7 sonnet, examples and docs is generated
|
|
116
|
-
|
|
117
|
-
Thank you!
|
|
118
|
-
|
|
119
|
-
## 🤝 Sponsors
|
|
120
|
-
|
|
121
|
-
The development of Gunshi is supported by my OSS sponsors!
|
|
122
|
-
|
|
123
|
-
<p align="center">
|
|
124
|
-
<a href="https://cdn.jsdelivr.net/gh/kazupon/sponsors/sponsors.svg">
|
|
125
|
-
<img src='https://cdn.jsdelivr.net/gh/kazupon/sponsors/sponsors.svg'/>
|
|
126
|
-
</a>
|
|
127
|
-
</p>
|
|
128
|
-
|
|
129
|
-
## ©️ License
|
|
130
|
-
|
|
131
|
-
[MIT](http://opensource.org/licenses/MIT)
|
|
132
|
-
|
|
133
|
-
<!-- Badges -->
|
|
134
|
-
|
|
135
|
-
[npm-version-src]: https://img.shields.io/npm/v/gunshi?style=flat
|
|
136
|
-
[npm-version-href]: https://npmjs.com/package/gunshi
|
|
137
|
-
[jsr-src]: https://jsr.io/badges/@kazupon/gunshi
|
|
138
|
-
[jsr-href]: https://jsr.io/@kazupon/gunshi
|
|
139
|
-
[install-size-src]: https://pkg-size.dev/badge/install/72346
|
|
140
|
-
[install-size-href]: https://pkg-size.dev/gunshi
|
|
141
|
-
[ci-src]: https://github.com/kazupon/gunshi/actions/workflows/ci.yml/badge.svg
|
|
142
|
-
[ci-href]: https://github.com/kazupon/gunshi/actions/workflows/ci.yml
|