@gunshi/bone 0.27.0-alpha.7 → 0.27.0-alpha.9

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
@@ -650,6 +650,33 @@ interface CommandContextExtension<E extends GunshiParams['extensions'] = Default
650
650
  readonly factory: (ctx: CommandContextCore, cmd: Command) => Awaitable<E>;
651
651
  readonly onFactory?: (ctx: Readonly<CommandContext>, cmd: Readonly<Command>) => Awaitable<void>;
652
652
  }
653
+ /**
654
+ * Rendering control options
655
+ * @since v0.27.0
656
+ */
657
+ interface RenderingOptions<G extends GunshiParamsConstraint = DefaultGunshiParams> {
658
+ /**
659
+ * Header rendering configuration
660
+ * - `null`: Disable rendering
661
+ * - `function`: Use custom renderer
662
+ * - `undefined` (when omitted): Use default renderer
663
+ */
664
+ header?: ((ctx: Readonly<CommandContext<G>>) => Promise<string>) | null;
665
+ /**
666
+ * Usage rendering configuration
667
+ * - `null`: Disable rendering
668
+ * - `function`: Use custom renderer
669
+ * - `undefined` (when omitted): Use default renderer
670
+ */
671
+ usage?: ((ctx: Readonly<CommandContext<G>>) => Promise<string>) | null;
672
+ /**
673
+ * Validation errors rendering configuration
674
+ * - `null`: Disable rendering
675
+ * - `function`: Use custom renderer
676
+ * - `undefined` (when omitted): Use default renderer
677
+ */
678
+ validationErrors?: ((ctx: Readonly<CommandContext<G>>, error: AggregateError) => Promise<string>) | null;
679
+ }
653
680
  /**
654
681
  * Command interface.
655
682
  */
@@ -696,6 +723,11 @@ interface Command<G extends GunshiParamsConstraint = DefaultGunshiParams> {
696
723
  * @since v0.27.0
697
724
  */
698
725
  entry?: boolean;
726
+ /**
727
+ * Rendering control options
728
+ * @since v0.27.0
729
+ */
730
+ rendering?: RenderingOptions<G>;
699
731
  }
700
732
  /**
701
733
  * Lazy command interface.
@@ -794,4 +826,4 @@ declare function cli<E extends ExtendContext = ExtendContext, G extends GunshiPa
794
826
  */
795
827
  declare function cli<G extends GunshiParams = DefaultGunshiParams>(argv: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
796
828
  //#endregion
797
- export { ArgSchema, ArgToken, ArgValues, Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, NormalizeToGunshiParams, RendererDecorator, ValidationErrorsDecorator, cli };
829
+ export { type ArgSchema, type ArgToken, type ArgValues, type Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, NormalizeToGunshiParams, RendererDecorator, RenderingOptions, ValidationErrorsDecorator, cli };
package/lib/index.js CHANGED
@@ -537,6 +537,15 @@ async function createCommandContext({ args, explicit, values, positionals, rest,
537
537
  */
538
538
  const env = Object.assign(create(), CLI_OPTIONS_DEFAULT, cliOptions);
539
539
  /**
540
+ * apply Command definition's rendering option with highest priority
541
+ */
542
+ if (command.rendering) {
543
+ const { header, usage, validationErrors } = command.rendering;
544
+ if (header !== void 0) env.renderHeader = header;
545
+ if (usage !== void 0) env.renderUsage = usage;
546
+ if (validationErrors !== void 0) env.renderValidationErrors = validationErrors;
547
+ }
548
+ /**
540
549
  * create the command context
541
550
  */
542
551
  const core = Object.assign(create(), {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gunshi/bone",
3
3
  "description": "gunshi minimum",
4
- "version": "0.27.0-alpha.7",
4
+ "version": "0.27.0-alpha.9",
5
5
  "author": {
6
6
  "name": "kazuya kawaguchi",
7
7
  "email": "kawakazu80@gmail.com"
@@ -51,15 +51,15 @@
51
51
  }
52
52
  },
53
53
  "devDependencies": {
54
- "deno": "^2.4.0",
54
+ "deno": "^2.4.2",
55
55
  "jsr": "^0.13.5",
56
56
  "jsr-exports-lint": "^0.4.1",
57
57
  "publint": "^0.3.12",
58
- "tsdown": "^0.12.9",
59
- "@gunshi/plugin-global": "0.27.0-alpha.7",
60
- "@gunshi/definition": "0.27.0-alpha.7",
61
- "@gunshi/plugin-renderer": "0.27.0-alpha.7",
62
- "gunshi": "0.27.0-alpha.7"
58
+ "tsdown": "^0.13.0",
59
+ "@gunshi/definition": "0.27.0-alpha.9",
60
+ "@gunshi/plugin-global": "0.27.0-alpha.9",
61
+ "gunshi": "0.27.0-alpha.9",
62
+ "@gunshi/plugin-renderer": "0.27.0-alpha.9"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "tsdown",