@gunshi/definition 1.0.0-rc.1 → 1.0.0-rc.2
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/index.d.ts +18 -3
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -1134,6 +1134,9 @@ interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams> {
|
|
|
1134
1134
|
* Output that must still appear — machine-readable results for an agent, warnings for the
|
|
1135
1135
|
* CLI author — should use `console.log` / `console.warn`, not `ctx.log`.
|
|
1136
1136
|
*
|
|
1137
|
+
* The validation errors are not printed either, so `cli()` rejects with them, for the caller to
|
|
1138
|
+
* report them (see {@linkcode CliOptions.renderValidationErrors}).
|
|
1139
|
+
*
|
|
1137
1140
|
* @default false
|
|
1138
1141
|
*/
|
|
1139
1142
|
usageSilent?: boolean;
|
|
@@ -1157,6 +1160,12 @@ interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams> {
|
|
|
1157
1160
|
renderHeader?: ((ctx: Readonly<CommandContext<G>>) => Promise<string>) | null;
|
|
1158
1161
|
/**
|
|
1159
1162
|
* Render function the validation errors.
|
|
1163
|
+
*
|
|
1164
|
+
* With the global options plugin, the rendered message is printed to stderr, the exit code is set
|
|
1165
|
+
* to `1`, {@linkcode CliOptions.onErrorCommand} is called, and `cli()` resolves with `undefined`.
|
|
1166
|
+
* Set it to `null` to report the validation errors yourself: nothing is printed, and `cli()` rejects
|
|
1167
|
+
* with the `AggregateError`. A renderer that returns an empty message, and
|
|
1168
|
+
* {@linkcode CliOptions.usageSilent}, also leave them to the caller.
|
|
1160
1169
|
*/
|
|
1161
1170
|
renderValidationErrors?: ((ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>) | null;
|
|
1162
1171
|
/**
|
|
@@ -1188,10 +1197,14 @@ interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams> {
|
|
|
1188
1197
|
*/
|
|
1189
1198
|
onAfterCommand?: (ctx: Readonly<CommandContext<G>>, result: string | undefined) => Awaitable<void>;
|
|
1190
1199
|
/**
|
|
1191
|
-
* Hook that runs when a command throws an error
|
|
1200
|
+
* Hook that runs when a command throws an error, or when the arguments fail validation
|
|
1201
|
+
*
|
|
1202
|
+
* For the validation errors that the global options plugin has printed, the exit code is already `1`
|
|
1203
|
+
* when the hook runs, so the hook can set another one, and `cli()` resolves after it. Any other
|
|
1204
|
+
* error rejects `cli()` after the hook.
|
|
1192
1205
|
*
|
|
1193
1206
|
* @param ctx - The command context
|
|
1194
|
-
* @param error - The error thrown during execution
|
|
1207
|
+
* @param error - The error thrown during execution, or the `AggregateError` of the validation errors
|
|
1195
1208
|
* @since v0.27.0
|
|
1196
1209
|
*/
|
|
1197
1210
|
onErrorCommand?: (ctx: Readonly<CommandContext<G>>, error: Error) => Awaitable<void>;
|
|
@@ -1360,9 +1373,11 @@ interface RenderingOptions<G extends GunshiParamsConstraint = DefaultGunshiParam
|
|
|
1360
1373
|
usage?: ((ctx: Readonly<CommandContext<G>>) => Promise<string>) | null;
|
|
1361
1374
|
/**
|
|
1362
1375
|
* Validation errors rendering configuration
|
|
1363
|
-
* - `null`: Disable rendering
|
|
1376
|
+
* - `null`: Disable rendering. `cli()` rejects with the validation errors, for the caller to report them
|
|
1364
1377
|
* - `function`: Use custom renderer
|
|
1365
1378
|
* - `undefined` (when omitted): Use default renderer
|
|
1379
|
+
*
|
|
1380
|
+
* See {@linkcode CliOptions.renderValidationErrors} for where the rendered message goes.
|
|
1366
1381
|
*/
|
|
1367
1382
|
validationErrors?: ((ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>) | null;
|
|
1368
1383
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gunshi/definition",
|
|
3
3
|
"description": "utilities for gunshi command definition",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.2",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"deno": "^2.7.14",
|
|
56
|
-
"gunshi": "1.0.0-rc.
|
|
56
|
+
"gunshi": "1.0.0-rc.2",
|
|
57
57
|
"jsr": "^0.14.3",
|
|
58
58
|
"jsr-exports-lint": "^0.4.2",
|
|
59
59
|
"publint": "^0.3.20",
|