@gunshi/plugin 1.0.0-beta.2 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/args-tokens@1.0.0-beta.1/node_modules/args-tokens/lib/parser-DhESN1gR.d.ts
1
+ //#region ../../node_modules/.pnpm/args-tokens@1.0.0/node_modules/args-tokens/lib/parser-DhESN1gR.d.ts
2
2
  //#region src/parser.d.ts
3
3
  /**
4
4
  * Entry point of argument parser.
@@ -56,7 +56,7 @@ interface ArgToken {
56
56
  inlineValue?: boolean | undefined;
57
57
  }
58
58
  //#endregion
59
- //#region ../../node_modules/.pnpm/args-tokens@1.0.0-beta.1/node_modules/args-tokens/lib/resolver.d.ts
59
+ //#region ../../node_modules/.pnpm/args-tokens@1.0.0/node_modules/args-tokens/lib/resolver.d.ts
60
60
  //#region src/resolver.d.ts
61
61
  /**
62
62
  * An argument schema definition for command-line argument parsing.
@@ -1397,6 +1397,9 @@ interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams> {
1397
1397
  * Output that must still appear — machine-readable results for an agent, warnings for the
1398
1398
  * CLI author — should use `console.log` / `console.warn`, not `ctx.log`.
1399
1399
  *
1400
+ * The validation errors are not printed either, so `cli()` rejects with them, for the caller to
1401
+ * report them (see {@linkcode CliOptions.renderValidationErrors}).
1402
+ *
1400
1403
  * @default false
1401
1404
  */
1402
1405
  usageSilent?: boolean;
@@ -1420,6 +1423,12 @@ interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams> {
1420
1423
  renderHeader?: ((ctx: Readonly<CommandContext<G>>) => Promise<string>) | null;
1421
1424
  /**
1422
1425
  * Render function the validation errors.
1426
+ *
1427
+ * With the global options plugin, the rendered message is printed to stderr, the exit code is set
1428
+ * to `1`, {@linkcode CliOptions.onErrorCommand} is called, and `cli()` resolves with `undefined`.
1429
+ * Set it to `null` to report the validation errors yourself: nothing is printed, and `cli()` rejects
1430
+ * with the `AggregateError`. A renderer that returns an empty message, and
1431
+ * {@linkcode CliOptions.usageSilent}, also leave them to the caller.
1423
1432
  */
1424
1433
  renderValidationErrors?: ((ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>) | null;
1425
1434
  /**
@@ -1451,10 +1460,14 @@ interface CliOptions<G extends GunshiParamsConstraint = DefaultGunshiParams> {
1451
1460
  */
1452
1461
  onAfterCommand?: (ctx: Readonly<CommandContext<G>>, result: string | undefined) => Awaitable<void>;
1453
1462
  /**
1454
- * Hook that runs when a command throws an error
1463
+ * Hook that runs when a command throws an error, or when the arguments fail validation
1464
+ *
1465
+ * For the validation errors that the global options plugin has printed, the exit code is already `1`
1466
+ * when the hook runs, so the hook can set another one, and `cli()` resolves after it. Any other
1467
+ * error rejects `cli()` after the hook.
1455
1468
  *
1456
1469
  * @param ctx - The command context
1457
- * @param error - The error thrown during execution
1470
+ * @param error - The error thrown during execution, or the `AggregateError` of the validation errors
1458
1471
  * @since v0.27.0
1459
1472
  */
1460
1473
  onErrorCommand?: (ctx: Readonly<CommandContext<G>>, error: Error) => Awaitable<void>;
@@ -1623,9 +1636,11 @@ interface RenderingOptions<G extends GunshiParamsConstraint = DefaultGunshiParam
1623
1636
  usage?: ((ctx: Readonly<CommandContext<G>>) => Promise<string>) | null;
1624
1637
  /**
1625
1638
  * Validation errors rendering configuration
1626
- * - `null`: Disable rendering
1639
+ * - `null`: Disable rendering. `cli()` rejects with the validation errors, for the caller to report them
1627
1640
  * - `function`: Use custom renderer
1628
1641
  * - `undefined` (when omitted): Use default renderer
1642
+ *
1643
+ * See {@linkcode CliOptions.renderValidationErrors} for where the rendered message goes.
1629
1644
  */
1630
1645
  validationErrors?: ((ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>) | null;
1631
1646
  }
package/lib/index.js CHANGED
@@ -176,7 +176,7 @@ function getCommandName(cmd) {
176
176
  "-".codePointAt(0);
177
177
  "=".codePointAt(0);
178
178
  //#endregion
179
- //#region ../../node_modules/.pnpm/args-tokens@1.0.0-beta.1/node_modules/args-tokens/lib/resolver-CAlgxe_R.js
179
+ //#region ../../node_modules/.pnpm/args-tokens@1.0.0/node_modules/args-tokens/lib/resolver-CAlgxe_R.js
180
180
  /**
181
181
  * @author kazuya kawaguchi (a.k.a. kazupon)
182
182
  * @license MIT
@@ -285,7 +285,7 @@ function isArgsValidationError$1(error) {
285
285
  return typeof values === "object" && values !== null;
286
286
  }
287
287
  //#endregion
288
- //#region ../../node_modules/.pnpm/args-tokens@1.0.0-beta.1/node_modules/args-tokens/lib/index.js
288
+ //#region ../../node_modules/.pnpm/args-tokens@1.0.0/node_modules/args-tokens/lib/index.js
289
289
  /**
290
290
  * @author kazuya kawaguchi (a.k.a. kazupon)
291
291
  * @license MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gunshi/plugin",
3
3
  "description": "plugin development kit for gunshi",
4
- "version": "1.0.0-beta.2",
4
+ "version": "1.0.0-rc.2",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "devDependencies": {
54
54
  "deno": "^2.7.14",
55
- "gunshi": "1.0.0-beta.2",
55
+ "gunshi": "1.0.0-rc.2",
56
56
  "jsr": "^0.14.3",
57
57
  "jsr-exports-lint": "^0.4.2",
58
58
  "publint": "^0.3.20",