@gunshi/plugin-renderer 0.37.1 → 0.37.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/README.md +3 -1
- package/lib/index.js +5 -4
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -214,13 +214,15 @@ await cli(args, command, {
|
|
|
214
214
|
plugins: [
|
|
215
215
|
i18n({
|
|
216
216
|
locale: 'ja-JP',
|
|
217
|
-
resources // Uses built-in resources from `@gunshi/resources`
|
|
217
|
+
builtinResources: resources // Uses built-in resources from `@gunshi/resources`
|
|
218
218
|
}),
|
|
219
219
|
renderer() // Will use Japanese translations
|
|
220
220
|
]
|
|
221
221
|
})
|
|
222
222
|
```
|
|
223
223
|
|
|
224
|
+
The renderer imports its error guards from `@gunshi/plugin`, which bundles its own copy of the error classes. It still recognizes and localizes validation errors thrown by `gunshi` or `@gunshi/bone`. Keep `gunshi` and all `@gunshi/*` packages on the same version: when an older copy throws an argument validation error such as a missing required option, the renderer cannot recognize it and falls back to the English message.
|
|
225
|
+
|
|
224
226
|
### Custom Rendering
|
|
225
227
|
|
|
226
228
|
You can create custom plugins that use the renderer functions while adding your own branding or logic:
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ANONYMOUS_COMMAND_NAME, ArgsValidationErrorKeys, isArgsValidationError, isCommandNotFoundError, plugin } from "@gunshi/plugin";
|
|
2
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
2
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.29.0/node_modules/args-tokens/lib/utils.js
|
|
3
3
|
/**
|
|
4
4
|
* Entry point of utils.
|
|
5
5
|
*
|
|
@@ -409,9 +409,10 @@ async function renderUsageSection(ctx) {
|
|
|
409
409
|
}
|
|
410
410
|
async function makeUsageSymbols(ctx) {
|
|
411
411
|
const messages = [await resolveEntry(ctx)];
|
|
412
|
-
if (ctx.omitted)
|
|
413
|
-
|
|
414
|
-
|
|
412
|
+
if (ctx.omitted) {
|
|
413
|
+
if (await hasCommands(ctx)) messages.push(` [${await ctx.extensions[pluginId].text(resolveBuiltInKey("COMMANDS"))}]`);
|
|
414
|
+
else messages.push(`${ctx.callMode === "subCommand" ? ` ${await resolveSubCommand(ctx)}` : ""}`);
|
|
415
|
+
} else messages.push(`${ctx.callMode === "subCommand" ? ` ${await resolveSubCommand(ctx)}` : ""}`);
|
|
415
416
|
const optionsSymbols = await generateOptionsSymbols(ctx, ctx.args);
|
|
416
417
|
if (optionsSymbols) messages.push(" ", optionsSymbols);
|
|
417
418
|
const positionalSymbols = generatePositionalSymbols(ctx.args);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gunshi/plugin-renderer",
|
|
3
3
|
"description": "usage renderer plugin for gunshi",
|
|
4
|
-
"version": "0.37.
|
|
4
|
+
"version": "0.37.3",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@gunshi/plugin": "0.37.
|
|
56
|
+
"@gunshi/plugin": "0.37.3"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@gunshi/plugin-i18n": "0.37.
|
|
59
|
+
"@gunshi/plugin-i18n": "0.37.3"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"deno": "^2.7.14",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"jsr-exports-lint": "^0.4.2",
|
|
65
65
|
"publint": "^0.3.20",
|
|
66
66
|
"tsdown": "0.21.0",
|
|
67
|
-
"@gunshi/shared": "0.37.
|
|
67
|
+
"@gunshi/shared": "0.37.3"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "tsdown",
|