8000 breaking: change the interfaces by kazupon · Pull Request #109 · kazupon/gunshi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

breaking: change the interfaces #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 5, 2025
Merged

Conversation

kazupon
Copy link
Owner
@kazupon kazupon commented May 5, 2025

Description

This PR is related to breaking changes in args-tokens.
About details, below issue links and copilot reviews

This PR is necessary to support positional arguments

Linked Issues

Additional context

Summary by CodeRabbit

  • Refactor
    • Unified naming conventions by renaming all command argument-related types and properties from "options" to "args" across the codebase for clarity and consistency.
    • Updated type imports and exports to use "Args" and "ArgSchema" instead of previous types.
    • Adjusted function signatures, interfaces, and test code to reflect the new naming scheme.
  • Chores
    • Upgraded the "args-tokens" dependency to version "^0.17.0".
    • Disabled Deno integration in VSCode settings.

Copy link
Contributor
coderabbitai bot commented May 5, 2025

Walkthrough

This update systematically renames the type and property for command argument definitions from options (typed as ArgOptions) to args (typed as Args) across the entire codebase. All relevant type parameters, imports, function signatures, property names, and test fixtures are updated to use the new terminology. The dependency on args-tokens is also updated from version ^0.16.2 to ^0.17.0. No changes are made to logic, control flow, or exported function/class behavior beyond this renaming and type alignment.

Changes

File(s) Change Summary
package.json Updated args-tokens dependency from ^0.16.2 to ^0.17.0.
src/cli.ts, src/context.ts, src/definition.ts, src/generator.ts, src/types.ts, src/utils.ts Replaced all type parameters and related code from options/ArgOptions to args/Args. Updated function signatures, variable names, and imports accordingly.
src/constants.ts, src/index.ts Updated type annotations and exported type aliases from ArgOptions to Args.
src/renderer/header.ts, src/renderer/usage.ts, src/renderer/validation.ts Updated all type parameters, imports, and function signatures from ArgOptions to Args. Replaced options with args in code.
src/cli.test.ts, src/context.test.ts, src/definition.test.ts, src/renderer.test.ts, src/types.test-d.ts Updated all test code to use args/Args instead of options/ArgOptions. Adjusted imports, type assertions, and property names.
test/fixtures/register.ts, test/fixtures/show.ts Renamed internal constants and command properties from options to args. Updated related type usages.
playground/, docs/guide/ Renamed all example and documentation code properties from options to args to reflect the new naming convention in examples.
.vscode/settings.json Added "deno.enable": false setting to disable Deno integration in VSCode.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Command
    participant ArgsParser

    User->>CLI: Provide argv (arguments array)
    CLI->>ArgsParser: Parse argv into args (was options)
    ArgsParser-->>CLI: Return parsed args
    CLI->>Command: Pass args to command handler
    Command-->>CLI: Execute with args
    CLI-->>User: Output result
Loading

Poem

In fields of code where rabbits hop,
We changed "options" to "args" atop!
Types are fresh, imports neat,
Every test now skips a beat.
From fixtures deep to CLI calls,
"Args" now echoes through the halls.
🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
pkg-pr-new bot commented May 5, 2025

Open in StackBlitz

npm i https://pkg.pr.new/kazupon/gunshi@109

commit: c44a542

@kazupon kazupon added the breaking Includes backwards-incompatible fixes label May 5, 2025
Copy link
cloudflare-workers-and-pages bot commented May 5, 2025

Deploying gunshi with  Cloudflare Pages  Cloudflare Pages

Latest commit: c44a542
Status: ✅  Deploy successful!
Preview URL: https://6d710afb.gunshi.pages.dev
Branch Preview URL: https://breaking-interface-changing.gunshi.pages.dev

View logs

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🔭 Outside diff range comments (2)
src/cli.test.ts (1)

235-240: ⚠️ Potential issue

Inconsistent property name in command3

While the PR has updated all other command definitions to use args instead of options, command3 (lines 235-240) still uses the options property. This is inconsistent with the rest of the changes and would likely cause runtime errors.

 const command3 = {
   name: 'command3',
   description: 'command3 description',
-  options: {
+  args: {
     qux: {
       type: 'number',
       short: 'q'
     }
   },
   run: vi.fn()
 }
src/renderer.test.ts (1)

68-74: ⚠️ Potential issue

One instance of options property not renamed in lazy command

The lazy command for command2 still uses the options property instead of args. This needs to be updated for consistency.

-    options: {
+    args: {
      bar: {
        type: 'boolean',
        short: 'b',
        description: 'The bar option'
      }
    },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d31e99 and 1c32a21.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (19)
  • package.json (1 hunks)
  • src/cli.test.ts (20 hunks)
  • src/cli.ts (9 hunks)
  • src/constants.ts (2 hunks)
  • src/context.test.ts (20 hunks)
  • src/context.ts (11 hunks)
  • src/definition.test.ts (3 hunks)
  • src/definition.ts (2 hunks)
  • src/generator.ts (2 hunks)
  • src/index.ts (1 hunks)
  • src/renderer.test.ts (18 hunks)
  • src/renderer/header.ts (1 hunks)
  • src/renderer/usage.ts (16 hunks)
  • src/renderer/validation.ts (2 hunks)
  • src/types.test-d.ts (2 hunks)
  • src/types.ts (13 hunks)
  • src/utils.ts (4 hunks)
  • test/fixtures/register.ts (2 hunks)
  • test/fixtures/show.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (6)
src/types.test-d.ts (2)
src/definition.ts (2)
  • Args (20-20)
  • define (27-29)
src/types.ts (1)
  • KeyOfArgOptions (23-31)
src/renderer/header.ts (1)
src/types.ts (1)
  • CommandContext (221-300)
src/generator.ts (1)
src/types.ts (2)
  • Command (305-334)
  • CommandOptions (151-215)
src/renderer/usage.ts (3)
src/definition.ts (2)
  • Args (20-20)
  • ArgSchema (20-20)
src/types.ts (2)
  • CommandContext (221-300)
  • Command (305-334)
src/utils.ts (1)
  • resolveBuiltInKey (63-67)
src/utils.ts (3)
src/definition.ts (1)
  • Args (20-20)
src/types.ts (6)
  • Commandable (445-445)
  • Command (305-334)
  • CommandBuiltinOptionsKeys (44-44)
  • CommandBuiltinResourceKeys (49-50)
  • GenerateNamespacedKey (36-39)
  • KeyOfArgOptions (23-31)
src/constants.ts (3)
  • BUILT_IN_PREFIX (14-14)
  • BUILT_IN_KEY_SEPARATOR (18-18)
  • OPTION_PREFIX (16-16)
src/context.ts (2)
src/types.ts (5)
  • Command (305-334)
  • CommandContext (221-300)
  • CommandEnvironment (74-146)
  • CommandBuiltinKeys (56-60)
  • CommandResource (339-350)
src/utils.ts (1)
  • create (85-87)
🪛 Biome (1.9.4)
src/utils.ts

[error] 70-70: Don't use '{}' as a type.

Prefer explicitly define the object shape. '{}' means "any non-nullable value".

(lint/complexity/noBannedTypes)

🪛 GitHub Check: Spell check with Typos
src/cli.ts

[warning] 36-36:
"Argments" should be "Arguments".


[warning] 86-86:
"Argments" should be "Arguments".

🪛 GitHub Actions: Typos
src/cli.ts

[error] 36-36: Typo detected: Argments should be Arguments at usage in code.


[error] 86-86: Typo detected: Argments should be Arguments in function name.

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (98)
package.json (1)

112-112: Dependency update matches interface changes

The version update from "^0.16.2" to "^0.17.0" aligns with the breaking changes mentioned in the PR objectives, supporting the renaming of interfaces from ArgOptions to Args.

src/constants.ts (2)

6-6: Updated import to reflect new interface naming

The import has been correctly changed from ArgOptions to Args to align with the breaking changes in the args-tokens package.


48-48: Updated type annotation for consistency

The type annotation for COMMAND_OPTIONS_DEFAULT has been properly updated to use Args instead of ArgOptions, maintaining type safety with the new interface.

src/index.ts (1)

18-18: Updated exported types to match new interface names

The type exports have been correctly updated to use the new interface names (Args, ArgSchema) from the args-tokens package while maintaining ArgValues. This change is consistent with the breaking changes described in the PR objectives.

test/fixtures/show.ts (3)

3-16: Renamed constant for consistent terminology

The object has been correctly renamed from options to args while maintaining the same structure and functionality.


18-18: Updated type reference in Command definition

The Command type parameter has been properly updated to reference the renamed constant.


21-21: Updated property name for consistency

The property name has been changed from options to args to match the new naming convention throughout the codebase.

src/definition.test.ts (3)

10-10: Property name updated correctly to args

The property has been updated from options to args in line with the breaking change to rename interfaces in the entire codebase. This change is consistent with the PR objectives.


29-29: Property name updated correctly to args

The property name has been correctly changed from options to args in this command definition, maintaining consistency with the rest of the codebase.


46-46: Assertion updated to match new property name

The assertion has been properly updated to check for args instead of options, ensuring the test reflects the new interface naming.

src/renderer/header.ts (2)

6-6: Import updated to use Args type

The import has been correctly updated to use Args from 'args-tokens' instead of the previous ArgOptions type, aligning with the breaking change.


14-16: Generic type parameter renamed consistently

The generic type parameter has been renamed from Options extends ArgOptions to A extends Args, and the function parameter type has been updated accordingly. This change is consistent with the naming pattern used in the CommandContext interface.

src/types.test-d.ts (3)

5-5: Import updated to use Args type

The import has been correctly updated to use Args from 'args-tokens' instead of the previous ArgOptions type.


9-9: Variable name and type assertion updated

The variable name has been changed from _options to _args, and the type assertion has been updated to use Args instead of ArgOptions. These changes maintain consistency with the new interface naming.

Also applies to: 20-21


28-28: Property name updated to args in command definition

The property key has been correctly changed from options to args in the command definition, ensuring the test uses the new interface naming convention.

src/renderer/validation.ts (2)

6-6: Import updated to use Args type

The import has been correctly updated to use Args from 'args-tokens' instead of the previous ArgOptions type.


15-17: Generic type parameter renamed consistently

The generic type parameter has been renamed from Options extends ArgOptions to A extends Args, and the function parameter type has been updated accordingly. This change maintains consistency with the naming pattern used throughout the codebase.

test/fixtures/register.ts (1)

3-3: Naming update looks good and is consistent with new interfaces

The renaming from options to args throughout this file (variable declaration, type parameter, and property reference) is consistent with the PR objective to update interface naming conventions.

Also applies to: 25-28

src/generator.ts (1)

20-20: Type parameter renaming is consistent and follows proper generic naming conventions

The update from ArgOptions to Args type import and the generic type parameter change from Options extends ArgOptions to A extends Args is well implemented. Using a short single-letter generic A is a common convention for the primary type parameter, which improves readability in this context.

Also applies to: 30-33

src/cli.test.ts (7)

7-7: Type import update is consistent with interface changes

The import change from ArgOptions to Args correctly aligns with the package interface updates.


42-47: Command argument property renamed correctly

The property rename from options to args is properly implemented for the command definition structure.


74-79: Consistent property renaming in sub-commands

The property rename from options to args is consistently applied across sub-command definitions.

Also applies to: 84-89


201-206: Type parameter update in lazy command definition

The lazy command's args property is correctly updated from options, maintaining consistent terminology throughout the codebase.


214-219: Command object property rename applied correctly

The remote command's property is correctly updated from options to args, ensuring consistency with the new interface.


273-278: Updated property access in renderUsage function

The property access in the renderUsage function is correctly updated from ctx.options to ctx.args, aligning with the other interface changes.

Also applies to: 493-493


320-325: Type declarations consistently updated

All type declarations and property definitions are consistently updated to use args instead of options throughout the test cases, including complex test scenarios, edge cases, and type assertions.

Also applies to: 357-364, 371-378, 470-545, 528-545, 600-609, 620-625, 635-647, 660-665, 687-693

src/context.test.ts (5)

14-14: Type import update is consistent with interface changes

The import change from ArgOptions to Args correctly aligns with the package interface updates.


18-40: Variable declaration and type assertion updates

Variable declarations and type assertions have been consistently updated from options to args throughout the test file.

Also applies to: 45-48


57-61: Parameter naming clarification in createCommandContext

The parameter name has been updated from options to args, and the CLI arguments parameter from args to argv, which provides better clarity about the purpose of each property.


87-87: Property access and frozen object checks updated

All property accesses and object validation checks have been correctly updated to use the new args property name instead of options.

Also applies to: 123-125, 135-138


226-242: Test assertions and resource declarations consistently updated

All test assertions, resource fetchers, and command declarations throughout the file have been consistently updated to use args instead of options.

Also applies to: 246-250, 267-269, 275-295, 306-306, 310-324, 350-356, 367-372, 379-379, 383-397, 422-428, 435-435, 439-453

src/renderer/usage.ts (8)

9-9: Updated type imports to use the new interface naming

The import statement is now using Args and ArgSchema types from 'args-tokens' instead of the previous ArgOptions and ArgOptionSchema, aligning with the breaking interface changes.


19-20: Type parameter renamed from Options extends ArgOptions to A extends Args

The generic type parameter has been updated to use the new Args type, with a shorter name A that's more concise while maintaining the same functionality.


196-196: Updated property reference from ctx.options to ctx.args

The property reference has been updated to use ctx.args instead of ctx.options, consistent with the interface renaming throughout the codebase.


205-205: Updated property reference from ctx.options to ctx.args

The property reference has been updated to use ctx.args instead of ctx.options for checking if all options have default values.


235-235: Updated property reference in object iteration from ctx.options to ctx.args

The property reference in the Object.entries() call has been updated to use ctx.args instead of ctx.options, aligning with the renamed interface.


251-251: Updated property reference in negatable type resolution from ctx.options to ctx.args

The property reference in resolveNegatableType function has been updated to use ctx.args instead of ctx.options.


269-269: Updated property reference in display value resolution from ctx.options to ctx.args

The property reference in resolveDisplayValue function has been updated to use ctx.args instead of ctx.options.


313-313: Updated property reference in negatable key handling from ctx.options to ctx.args

The property reference when retrieving schema for a negatable key has been updated to use ctx.args instead of ctx.options.

src/renderer.test.ts (16)

5-5: Updated type import to use Args instead of ArgOptions

The import statement now uses the Args type from 'args-tokens', aligning with the breaking interface changes.


15-15: Renamed property from options to args in test fixture

The test fixture SHOW is now using the args property instead of options to align with the interface changes.


49-49: Updated type assertion to use Command<Args> instead of Command<ArgOptions>

The type assertion for the SHOW fixture has been updated to use the new Args type.


51-51: Updated Map generic type parameters to use Args

The type parameter for the COMMANDS Map has been updated to use the new Args type.


55-55: Renamed property from options to args in command definition

The command1 definition now uses the args property instead of options to align with the interface changes.


85-85: Updated type assertions and property names in test context creation

The type assertion now uses Command<Args> and the context creation uses the args property instead of options. Also, args property in createCommandContext has been renamed to argv to be consistent with the new terminology.

Also applies to: 89-94


110-114: Renamed properties in context creation consistently

The context creation function calls have been updated to use args instead of options and argv instead of args across all test cases, ensuring consistency.


130-134: Renamed properties in context creation

The test for "no name & no description" has been updated to use the new property names consistently.


146-150: Renamed properties in context creation

The test for "no version" has been updated to use the new property names consistently.


168-168: Renamed property from options to args in test fixture

The command definition in "renderUsage" test now uses the args property instead of options.


195-201: Updated type assertion and property references

The type assertion now uses Command<Args> and the context creation accesses the args property with the non-null assertion operator.


245-245: Renamed property from options to args in test fixture

The command definition in "no required options" test now uses the args property instead of options.


287-287: Renamed property from options to args in test fixture

The command definition in "no examples" test now uses the args property instead of options.


335-335: Renamed property from options to args in test fixture

The command definition in "enable usageOptionType" test now uses the args property instead of options.


387-392: Updated property references in context creation for sub commands test

The context creation now accesses the args property with the non-null assertion operator and uses argv instead of args for the command line arguments.


409-413: Updated property references in context creation for validation errors test

The context creation for the validation errors test now uses the new property names consistently.

src/definition.ts (5)

17-17: Updated type import to use Args instead of ArgOptions

The import statement now uses the Args type from 'args-tokens', aligning with the breaking interface changes.


20-20: Updated re-export to use Args, ArgSchema instead of ArgOptions, ArgOptionSchema

The re-export statement now uses the new type names, ensuring consumers of this module will use the new terminology.


27-27: Updated function signature to use A extends Args instead of previous type

The define function now uses the new generic type parameter name and constraint.


37-40: Updated function signature to use A extends Args in lazy function

The lazy function now uses the new generic type parameter name and constraint for all parameters.


42-46: Renamed property assignments in lazy function from .options to .args

The property assignments in the lazy function have been updated to use .args instead of .options when adding metadata to the loader function.

src/types.ts (14)

6-6: Updated type imports to use Args instead of ArgOptions

The import statement now uses the Args type from 'args-tokens', aligning with the breaking interface changes.


23-31: Updated KeyOfArgOptions type to use A extends Args

The utility type has been renamed from KeyOfArgOptions to use the new Args type parameter, while maintaining the same functionality for extracting keys including negatable boolean options.


66-68: Updated CommandOptionKeys type to use A extends Args

The utility type now uses the new Args type parameter, maintaining the same functionality for generating namespaced option keys.


74-74: Updated CommandEnvironment interface to use A extends Args

The interface now uses the new Args type parameter.


134-138: Updated render function signatures in CommandEnvironment to use new type parameter

The render function types now use the updated CommandContext<A> with the new type parameter.


142-145: Updated validation errors render function signature

The validation errors render function type now uses the updated CommandContext<A> with the new type parameter.


151-151: Updated CommandOptions interface to use A extends Args

The interface now uses the new Args type parameter.


200-209: Updated render function signatures in CommandOptions to use new type parameter

The render function types now use the updated CommandContext<A> with the new type parameter.


221-245: Updated CommandContext interface to use A extends Args

The interface now uses the new Args type parameter, and the property has been renamed from options to args with updated documentation comments to reflect this change.


285-299: Updated function signatures and type parameters in CommandContext

The loadCommands return type and translate function type parameters now use the updated A extends Args type parameter.


305-320: Updated Command interface to use A extends Args

The interface now uses the new Args type parameter, and the property has been renamed from options to args with updated documentation comments to reflect this change.


329-333: Updated function signatures in Command interface

The run and resource property types now use the updated A extends Args type parameter.


339-359: Updated CommandResource and CommandResourceFetcher types

These types now use the updated A extends Args type parameter, maintaining the same functionality.


421-445: Updated remaining command-related types

The CommandRunner, CommandLoader, LazyCommand, and Commandable types now use the updated A extends Args type parameter.

src/utils.ts (5)

8-8: LGTM! Nice update to the imports.

The import statement for Args from 'args-tokens' correctly reflects the package's newer type system.


19-23: Correct type parameter renaming.

The generic type parameter has been appropriately renamed from Options extends ArgOptions to A extends Args to align with the new type system from args-tokens.


29-29: Property access update is consistent.

Properly renamed property access from options to args to maintain consistency with the new type naming convention.


45-45: Property access update is consistent.

Properly renamed property access from options to args to maintain consistency with the new type naming convention.


63-67: Generic parameter update is correct.

The type signature for resolveBuiltInKey has been updated to align with the new type system.

src/context.ts (10)

30-30: LGTM! Updated imports align with new type system.

The import statement correctly brings in the new types from args-tokens.


45-50: Interface properly updated with new type parameter and property name.

The CommandContextParams interface has been correctly updated to use A extends Args and renamed the options property to args.


65-65: Parameter renamed for clarity.

Appropriately renamed from args to argv to better distinguish between command-line arguments and the typed argument schema.


89-102: Function signature updated to use new generic type.

The createCommandContext function's signature has been correctly updated to use A extends Args and V extends ArgValues<A> instead of the previous Options and Values types.


107-110: Variable and type update is consistent.

Properly updated variable from accessing args as Args and creating a new Args type.


158-161: Translation function type parameters updated correctly.

The translate function's type parameters have been properly updated to use keyof A instead of the previous type.


181-182: Cached commands type update is consistent.

The type for cachedCommands and the return type of loadCommands have been properly updated to use Command<A>[].


198-209: Context creation uses correct property names.

The context creation now correctly uses args instead of options and assigns argv to the _ property.


222-226: Renamed variable and property access is appropriate.

The variable access has been renamed from options to args and property access updated accordingly.


236-269: Function signatures updated properly.

The loadCommandResource function signature has been appropriately updated to use the new generic type parameters.

src/cli.ts (9)

12-12: LGTM! Updated imports align with new type system.

The import statement correctly brings in the new types from args-tokens.


22-26: Function signature properly updated.

The cli function signature has been correctly updated to use A extends Args instead of the previous type.


90-106: Type parameters and return type properly updated.

The resolveCommandOptions function has been correctly updated to use the new type parameters.


120-129: Function signature properly updated.

The showUsage function has been correctly updated to use A extends Args instead of the previous type.


131-133: Function signature properly updated.

The showVersion function has been correctly updated to use A extends Args instead of the previous type.


135-145: Function signature properly updated.

The showHeader function has been correctly updated to use A extends Args instead of the previous type.


147-156: Function signature properly updated.

The showValidationErrors function has been correctly updated to use A extends Args instead of the previous type.


158-186: Function signature and parameters properly updated.

The resolveCommand function has been correctly updated to use the new type parameters.


188-190: Function signature properly updated.

The resolveEntryName function has been correctly updated to use A extends Args instead of the previous type.

Comment on lines 69 to 73
export function resolveOptionKey<
Options extends ArgOptions = {},
Key extends string = KeyOfArgOptions<RemovedIndex<Options>>
>(key: Key): GenerateNamespacedKey<Key, typeof OPTION_PREFIX> {
A extends Args = {},
K extends string = KeyOfArgOptions<RemovedIndex<A>>
>(key: K): GenerateNamespacedKey<K, typeof OPTION_PREFIX> {
return `${OPTION_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Generic parameter update needs improvement.

The empty object type {} used as a default generic parameter should be avoided.

-export function resolveOptionKey<
-  A extends Args = {},
-  K extends string = KeyOfArgOptions<RemovedIndex<A>>
->(key: K): GenerateNamespacedKey<K, typeof OPTION_PREFIX> {
+export function resolveOptionKey<
+  A extends Args = Args,
+  K extends string = KeyOfArgOptions<RemovedIndex<A>>
+>(key: K): GenerateNamespacedKey<K, typeof OPTION_PREFIX> {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function resolveOptionKey<
Options extends ArgOptions = {},
Key extends string = KeyOfArgOptions<RemovedIndex<Options>>
>(key: Key): GenerateNamespacedKey<Key, typeof OPTION_PREFIX> {
A extends Args = {},
K extends string = KeyOfArgOptions<RemovedIndex<A>>
>(key: K): GenerateNamespacedKey<K, typeof OPTION_PREFIX> {
return `${OPTION_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`
export function resolveOptionKey<
A extends Args = Args,
K extends string = KeyOfArgOptions<RemovedIndex<A>>
>(key: K): GenerateNamespacedKey<K, typeof OPTION_PREFIX> {
return `${OPTION_PREFIX}${BUILT_IN_KEY_SEPARATOR}${key}`
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 70-70: Don't use '{}' as a type.

Prefer explicitly define the object shape. '{}' means "any non-nullable value".

(lint/complexity/noBannedTypes)

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (2)
docs/guide/essentials/declarative-configuration.md (2)

16-18: ⚠️ Potential issue

Note: Missed property rename in basic structure example

The property name in the basic declarative structure example still uses options instead of args. This should be updated to maintain consistency with the interface changes.

Apply this diff to fix the inconsistency:

  // Command options
-  options: {
+  args: {
    // Option definitions
  },

140-142: 🛠️ Refactor suggestion

Update section title to match new terminology

The section titled "Command Options" should be updated to "Command Arguments" to maintain consistency with the interface changes.

Apply this diff to update the section title:

-### Command Options
+### Command Arguments
🧹 Nitpick comments (2)
docs/guide/essentials/internationalization.md (1)

250-251: Consider updating the terminology in documentation text

The documentation text still refers to "Option Descriptions" and mentions that keys for descriptions of command options must be prefixed with Option:. Since the property has been renamed from options to args, consider updating this terminology for complete consistency.

- **Option Descriptions**: Keys for the descriptions of command options **must** be prefixed with `Option:`. For example, if you have an option named `target`, its description key must be `Option:target`.
- **Negatable Option Descriptions**: For boolean options (e.g., `--verbose`), Gunshi automatically generates a description for the negatable version (e.g., `--no-verbose`) using the built-in `NEGATABLE` key (e.g., "Negatable of --verbose"). To provide a custom translation for a specific negatable option, use the pattern `Option:no-<optionName>`, for example, `Option:no-verbose`.
+ **Argument Descriptions**: Keys for the descriptions of command arguments **must** be prefixed with `Option:`. For example, if you have an argument named `target`, its description key must be `Option:target`.
+ **Negatable Argument Descriptions**: For boolean arguments (e.g., `--verbose`), Gunshi automatically generates a description for the negatable version (e.g., `--no-verbose`) using the built-in `NEGATABLE` key (e.g., "Negatable of --verbose"). To provide a custom translation for a specific negatable argument, use the pattern `Option:no-<optionName>`, for example, `Option:no-verbose`.
docs/guide/essentials/declarative-configuration.md (1)

175-175: Interface update: renamed 'options' to 'args' in context object description

The context object property description has been updated from options to args to align with the breaking interface changes.

There appears to be a formatting issue here. Add a colon after "with" to match the style of other list items:

-The `run` function receives a command context object (`ctx`) with:
+The `run` function receives a command context object (`ctx`) with:
🧰 Tools
🪛 LanguageTool

[uncategorized] ~175-~175: Loose punctuation mark.
Context: ...d context object (ctx) with: - args: The command arguments configuration - `...

(UNLIKELY_OPENING_PUNCTUATION)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 99bc78b and c44a542.

⛔ Files ignored due to path filters (1)
  • playground/deno/deno.lock is excluded by !**/*.lock
📒 Files selected for processing (25)
  • .vscode/settings.json (1 hunks)
  • docs/guide/advanced/custom-usage-generation.md (8 hunks)
  • docs/guide/advanced/documentation-generation.md (6 hunks)
  • docs/guide/advanced/translation-adapter.md (3 hunks)
  • docs/guide/essentials/auto-usage-generation.md (2 hunks)
  • docs/guide/essentials/composable.md (2 hunks)
  • docs/guide/essentials/declarative-configuration.md (2 hunks)
  • docs/guide/essentials/getting-started.md (1 hunks)
  • docs/guide/essentials/internationalization.md (6 hunks)
  • docs/guide/essentials/lazy-async.md (5 hunks)
  • docs/guide/essentials/type-safe.md (3 hunks)
  • playground/auto-usage/index.js (1 hunks)
  • playground/bun/index.ts (2 hunks)
  • playground/composable/index.js (4 hunks)
  • playground/custom-usage/index.js (2 hunks)
  • playground/declarative/index.js (2 hunks)
  • playground/deno/deno.json (1 hunks)
  • playground/deno/main.ts (2 hunks)
  • playground/docs-gen/index.js (1 hunks)
  • playground/i18n/index.js (1 hunks)
  • playground/lazy-async/index.js (2 hunks)
  • playground/modularization-lazy-async/commands/bar/meta.js (1 hunks)
  • playground/modularization-lazy-async/commands/foo/meta.js (1 hunks)
  • playground/type-safe-lazy-async/index.ts (2 hunks)
  • playground/type-safe/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (8)
  • playground/deno/deno.json
  • .vscode/settings.json
  • docs/guide/essentials/type-safe.md
  • docs/guide/advanced/documentation-generation.md
  • docs/guide/advanced/translation-adapter.md
  • docs/guide/advanced/custom-usage-generation.md
  • docs/guide/essentials/lazy-async.md
  • docs/guide/essentials/composable.md
🧰 Additional context used
🪛 LanguageTool
docs/guide/essentials/declarative-configuration.md

[uncategorized] ~175-~175: Loose punctuation mark.
Context: ...d context object (ctx) with: - args: The command arguments configuration - `...

(UNLIKELY_OPENING_PUNCTUATION)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (33)
playground/modularization-lazy-async/commands/foo/meta.js (1)

4-4: Breaking change: Renamed options to args

This is part of the PR's intended breaking change to standardize the naming convention for command argument definitions. The rename from options to args is more appropriate for supporting positional arguments as mentioned in the PR objectives.

playground/i18n/index.js (1)

11-11: Breaking change: Renamed options to args

This property rename aligns with the PR's breaking changes to support positional arguments. The command's functionality remains intact as all argument references in the run function (via ctx.values) are unchanged.

playground/docs-gen/index.js (1)

9-9: Breaking change: Renamed options to args

This property rename is consistent with the standardization effort across the codebase to support positional arguments. The implementation details in the run function remain unaffected as arguments are still accessed via ctx.values.

playground/modularization-lazy-async/commands/bar/meta.js (1)

4-4: Breaking change: Renamed options to args

This property rename completes the standardization of command argument definitions. The command definition remains functionally identical, with only the property name changing from options to args.

docs/guide/essentials/getting-started.md (1)

70-70: Property name updated to align with the new API.

The change from options to args is part of a breaking change to support positional arguments, as mentioned in the PR objectives. This update correctly reflects the new API in the documentation example.

playground/type-safe/index.ts (1)

9-9: Property name updated to align with the new API.

The change from options to args is consistent with the breaking changes being introduced to support positional arguments. This ensures the type-safe example remains compatible with the updated API.

playground/bun/index.ts (2)

8-8: Property name updated for createCommand definition.

The renaming from options to args in the createCommand definition aligns with the breaking changes being implemented across the codebase.


34-34: Property name updated for mainCommand definition.

The renaming from options to args in the mainCommand definition maintains consistency with the API changes.

playground/lazy-async/index.js (2)

14-14: Property name updated in lazyCommandDefinition.

The change from options to args in the lazyCommandDefinition is part of the consistent renaming across the codebase to support the new positional arguments feature.


53-53: Property name updated in asyncDataDefinition.

The change from options to args in the asyncDataDefinition aligns with the breaking changes being introduced to the API.

playground/custom-usage/index.js (3)

11-11: Property rename from options to args looks good

This change is part of a breaking change to rename the property for command argument definitions from options to args throughout the codebase. The change is consistent with the PR objectives.


102-102: Property reference updated correctly

The context property reference has been updated from ctx.options to ctx.args to align with the renamed property.


105-105: Object.entries iteration updated correctly

The iteration over command arguments has been properly updated to use ctx.args instead of ctx.options.

playground/auto-usage/index.js (1)

11-12: Comment and property renamed consistently

Both the comment describing arguments and the property name have been updated from options to args. This maintains consistency with the breaking change throughout the codebase.

playground/declarative/index.js (2)

12-13: Comment and property renamed consistently

Both the comment and property have been updated from "options" to "args", maintaining consistency with the breaking change.


52-52: Console log statement updated correctly

The console.log statement has been updated to reflect the property rename from ctx.options to ctx.args, and the label has been updated from 'Options:' to 'Args:' for consistency.

docs/guide/essentials/internationalization.md (2)

23-23: Documentation examples updated consistently

All code examples in the internationalization documentation have been updated to use the args property instead of options. This ensures the documentation remains in sync with the code changes.

Also applies to: 118-118, 182-182, 262-262, 324-324, 385-385


1-467:

✅ Verification successful

Verify if the Option: prefix needs to be renamed

The codebase has been updated to rename options to args, but the translation key prefix remains Option: in all documentation examples (lines 40-41, 50-51, 156-157, 168-169, 272-273, 450-451, 462-463). Verify if this prefix should also be renamed for consistency, or if it should remain as Option: despite the property rename.


🏁 Script executed:

#!/bin/bash
# Check if the Option: prefix is used in the actual code

# Look for translation keys with Option: prefix
rg -A 1 "Option:" --type ts src/

Length of output: 1732


No change needed for Option: prefix
The codebase (e.g. resolveOptionKey and its tests in src/context.test.ts) still expects translation keys to be prefixed with Option:. The documentation examples are already correct and should remain as-is.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~151-~151: Loose punctuation mark.
Context: ...mple locale files: locales/en-US.json: ```json { "description": "Greeting a...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~163-~163: Loose punctuation mark.
Context: ...: "Good day" } `locales/ja-JP.json`: json { "description": "挨拶アプリケーション...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~445-~445: Loose punctuation mark.
Context: ...With locale files: locales/en-US.json: ```json { "description": "Greeting a...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~457-~457: Loose punctuation mark.
Context: ...: "Good day" } `locales/ja-JP.json`: json { "description": "挨拶アプリケーション...

(UNLIKELY_OPENING_PUNCTUATION)

docs/guide/essentials/auto-usage-generation.md (2)

16-17: Interface update: replaced 'options' property with 'args'

This change is part of the breaking interface update mentioned in the PR description. The command argument definition property has been renamed from options to args to better support positional arguments.


119-119: Interface update: renamed property in createCommand from 'options' to 'args'

Consistent renaming of the command argument definition property from options to args in the subcommand example.

playground/composable/index.js (4)

10-10: Interface update: renamed 'options' to 'args' in createCommand

The property for defining command arguments has been renamed from options to args to align with the breaking interface changes.


34-34: Interface update: renamed 'options' to 'args' in listCommand

The property for defining command arguments has been renamed from options to args to align with the breaking interface changes.


63-63: Interface update: renamed 'options' to 'args' in deleteCommand

The property for defining command arguments has been renamed from options to args to align with the breaking interface changes.


98-99: Interface update: renamed 'options' to 'args' in mainCommand

The property for defining command arguments has been renamed from options to args to align with the breaking interface changes. The comment has also been updated accordingly.

playground/deno/main.ts (2)

11-11: Interface update: renamed 'options' to 'args' in createCommand

Consistent renaming of the command argument definition property from options to args to align with the breaking interface changes in the Deno TypeScript implementation.


48-48: Interface update: renamed 'options' to 'args' in mainCommand

Consistent renaming of the command argument definition property from options to args to align with the breaking interface changes in the Deno TypeScript implementation.

docs/guide/essentials/declarative-configuration.md (1)

43-44: Interface update: renamed 'options' to 'args' in command definition

The property for defining command arguments has been renamed from options to args to align with the breaking interface changes. The comment has also been updated accordingly.

playground/type-safe-lazy-async/index.ts (6)

9-9: Interface updated from options to args as described in PR

The property has been correctly renamed from options to args in this command definition, aligning with the breaking change mentioned in the PR objectives.


19-19: Type alias renamed from HelloOptions to HelloArgs

The type alias has been properly renamed and its reference to helloDefinition.args has been updated to match the new property name.


22-24: Comments updated to reflect new type naming

The documentation comments have been updated to correctly reference the new type naming convention using HelloArgs.


24-24: Return type updated from CommandRunner<HelloOptions> to CommandRunner<HelloArgs>

The loader function's return type has been properly updated to maintain type consistency with the renamed interfaces.


32-33: Parameter type updated for context object

The context parameter type and associated comment have been correctly updated to reflect the new type system.


1-63:

✅ Verification successful

Verify the version compatibility with updated args-tokens dependency

The code changes properly reflect the interface renaming from "options" to "args" to support positional arguments. Since this integrates with the updated args-tokens dependency (from ^0.16.2 to ^0.17.0 as mentioned in the AI summary), make sure your package.json is also updated accordingly.


🏁 Script executed:

#!/bin/bash
# Check if package.json has been updated with the correct args-tokens version
grep -r "args-tokens" --include="package*.json" .

Length of output: 93


args-tokens dependency version confirmed

The package.json specifies "args-tokens": "^0.17.0", matching the required update for the renamed “args” interface. No further changes are needed.

@kazupon kazupon merged commit e250b78 into main May 5, 2025
10 checks passed
@kazupon kazupon deleted the breaking/interface-changing branch May 5, 2025 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Includes backwards-incompatible fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0