breaking: change the interfaces - #109
Conversation
WalkthroughThis update systematically renames the type and property for command argument definitions from Changes
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
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@gunshi/bone
@gunshi/definition
gunshi
@gunshi/plugin
@gunshi/plugin-completion
@gunshi/plugin-dryrun
@gunshi/plugin-global
@gunshi/plugin-i18n
@gunshi/plugin-renderer
@gunshi/resources
@gunshi/shared
commit: |
Deploying gunshi with
|
| Latest commit: |
c44a542
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6d710afb.gunshi.pages.dev |
| Branch Preview URL: | https://breaking-interface-changing.gunshi.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 3
🔭 Outside diff range comments (2)
src/cli.test.ts (1)
235-240:⚠️ Potential issueInconsistent property name in command3
While the PR has updated all other command definitions to use
argsinstead ofoptions, command3 (lines 235-240) still uses theoptionsproperty. 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 issueOne instance of
optionsproperty not renamed in lazy commandThe lazy command for command2 still uses the
optionsproperty instead ofargs. 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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis 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 changesThe 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
ArgOptionstoArgs.src/constants.ts (2)
6-6: Updated import to reflect new interface namingThe import has been correctly changed from
ArgOptionstoArgsto align with the breaking changes in the args-tokens package.
48-48: Updated type annotation for consistencyThe type annotation for
COMMAND_OPTIONS_DEFAULThas been properly updated to useArgsinstead ofArgOptions, maintaining type safety with the new interface.src/index.ts (1)
18-18: Updated exported types to match new interface namesThe type exports have been correctly updated to use the new interface names (
Args,ArgSchema) from the args-tokens package while maintainingArgValues. This change is consistent with the breaking changes described in the PR objectives.test/fixtures/show.ts (3)
3-16: Renamed constant for consistent terminologyThe object has been correctly renamed from
optionstoargswhile maintaining the same structure and functionality.
18-18: Updated type reference in Command definitionThe Command type parameter has been properly updated to reference the renamed constant.
21-21: Updated property name for consistencyThe property name has been changed from
optionstoargsto match the new naming convention throughout the codebase.src/definition.test.ts (3)
10-10: Property name updated correctly toargsThe property has been updated from
optionstoargsin 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 toargsThe property name has been correctly changed from
optionstoargsin this command definition, maintaining consistency with the rest of the codebase.
46-46: Assertion updated to match new property nameThe assertion has been properly updated to check for
argsinstead ofoptions, ensuring the test reflects the new interface naming.src/renderer/header.ts (2)
6-6: Import updated to useArgstypeThe import has been correctly updated to use
Argsfrom 'args-tokens' instead of the previousArgOptionstype, aligning with the breaking change.
14-16: Generic type parameter renamed consistentlyThe generic type parameter has been renamed from
Options extends ArgOptionstoA extends Args, and the function parameter type has been updated accordingly. This change is consistent with the naming pattern used in theCommandContextinterface.src/types.test-d.ts (3)
5-5: Import updated to useArgstypeThe import has been correctly updated to use
Argsfrom 'args-tokens' instead of the previousArgOptionstype.
9-9: Variable name and type assertion updatedThe variable name has been changed from
_optionsto_args, and the type assertion has been updated to useArgsinstead ofArgOptions. These changes maintain consistency with the new interface naming.Also applies to: 20-21
28-28: Property name updated toargsin command definitionThe property key has been correctly changed from
optionstoargsin the command definition, ensuring the test uses the new interface naming convention.src/renderer/validation.ts (2)
6-6: Import updated to useArgstypeThe import has been correctly updated to use
Argsfrom 'args-tokens' instead of the previousArgOptionstype.
15-17: Generic type parameter renamed consistentlyThe generic type parameter has been renamed from
Options extends ArgOptionstoA 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 interfacesThe renaming from
optionstoargsthroughout 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 conventionsThe update from
ArgOptionstoArgstype import and the generic type parameter change fromOptions extends ArgOptionstoA extends Argsis well implemented. Using a short single-letter genericAis 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 changesThe import change from
ArgOptionstoArgscorrectly aligns with the package interface updates.
42-47: Command argument property renamed correctlyThe property rename from
optionstoargsis properly implemented for the command definition structure.
74-79: Consistent property renaming in sub-commandsThe property rename from
optionstoargsis consistently applied across sub-command definitions.Also applies to: 84-89
201-206: Type parameter update in lazy command definitionThe lazy command's
argsproperty is correctly updated fromoptions, maintaining consistent terminology throughout the codebase.
214-219: Command object property rename applied correctlyThe remote command's property is correctly updated from
optionstoargs, ensuring consistency with the new interface.
273-278: Updated property access in renderUsage functionThe property access in the renderUsage function is correctly updated from
ctx.optionstoctx.args, aligning with the other interface changes.Also applies to: 493-493
320-325: Type declarations consistently updatedAll type declarations and property definitions are consistently updated to use
argsinstead ofoptionsthroughout 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 changesThe import change from
ArgOptionstoArgscorrectly aligns with the package interface updates.
18-40: Variable declaration and type assertion updatesVariable declarations and type assertions have been consistently updated from
optionstoargsthroughout the test file.Also applies to: 45-48
57-61: Parameter naming clarification in createCommandContextThe parameter name has been updated from
optionstoargs, and the CLI arguments parameter fromargstoargv, which provides better clarity about the purpose of each property.
87-87: Property access and frozen object checks updatedAll property accesses and object validation checks have been correctly updated to use the new
argsproperty name instead ofoptions.Also applies to: 123-125, 135-138
226-242: Test assertions and resource declarations consistently updatedAll test assertions, resource fetchers, and command declarations throughout the file have been consistently updated to use
argsinstead ofoptions.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 namingThe import statement is now using
ArgsandArgSchematypes from 'args-tokens' instead of the previousArgOptionsandArgOptionSchema, aligning with the breaking interface changes.
19-20: Type parameter renamed fromOptions extends ArgOptionstoA extends ArgsThe generic type parameter has been updated to use the new
Argstype, with a shorter nameAthat's more concise while maintaining the same functionality.
196-196: Updated property reference fromctx.optionstoctx.argsThe property reference has been updated to use
ctx.argsinstead ofctx.options, consistent with the interface renaming throughout the codebase.
205-205: Updated property reference fromctx.optionstoctx.argsThe property reference has been updated to use
ctx.argsinstead ofctx.optionsfor checking if all options have default values.
235-235: Updated property reference in object iteration fromctx.optionstoctx.argsThe property reference in the
Object.entries()call has been updated to usectx.argsinstead ofctx.options, aligning with the renamed interface.
251-251: Updated property reference in negatable type resolution fromctx.optionstoctx.argsThe property reference in
resolveNegatableTypefunction has been updated to usectx.argsinstead ofctx.options.
269-269: Updated property reference in display value resolution fromctx.optionstoctx.argsThe property reference in
resolveDisplayValuefunction has been updated to usectx.argsinstead ofctx.options.
313-313: Updated property reference in negatable key handling fromctx.optionstoctx.argsThe property reference when retrieving schema for a negatable key has been updated to use
ctx.argsinstead ofctx.options.src/renderer.test.ts (16)
5-5: Updated type import to useArgsinstead ofArgOptionsThe import statement now uses the
Argstype from 'args-tokens', aligning with the breaking interface changes.
15-15: Renamed property fromoptionstoargsin test fixtureThe test fixture SHOW is now using the
argsproperty instead ofoptionsto align with the interface changes.
49-49: Updated type assertion to useCommand<Args>instead ofCommand<ArgOptions>The type assertion for the SHOW fixture has been updated to use the new
Argstype.
51-51: Updated Map generic type parameters to useArgsThe type parameter for the COMMANDS Map has been updated to use the new
Argstype.
55-55: Renamed property fromoptionstoargsin command definitionThe command1 definition now uses the
argsproperty instead ofoptionsto align with the interface changes.
85-85: Updated type assertions and property names in test context creationThe type assertion now uses
Command<Args>and the context creation uses theargsproperty instead ofoptions. Also,argsproperty in createCommandContext has been renamed toargvto be consistent with the new terminology.Also applies to: 89-94
110-114: Renamed properties in context creation consistentlyThe context creation function calls have been updated to use
argsinstead ofoptionsandargvinstead ofargsacross all test cases, ensuring consistency.
130-134: Renamed properties in context creationThe test for "no name & no description" has been updated to use the new property names consistently.
146-150: Renamed properties in context creationThe test for "no version" has been updated to use the new property names consistently.
168-168: Renamed property fromoptionstoargsin test fixtureThe command definition in "renderUsage" test now uses the
argsproperty instead ofoptions.
195-201: Updated type assertion and property referencesThe type assertion now uses
Command<Args>and the context creation accesses theargsproperty with the non-null assertion operator.
245-245: Renamed property fromoptionstoargsin test fixtureThe command definition in "no required options" test now uses the
argsproperty instead ofoptions.
287-287: Renamed property fromoptionstoargsin test fixtureThe command definition in "no examples" test now uses the
argsproperty instead ofoptions.
335-335: Renamed property fromoptionstoargsin test fixtureThe command definition in "enable usageOptionType" test now uses the
argsproperty instead ofoptions.
387-392: Updated property references in context creation for sub commands testThe context creation now accesses the
argsproperty with the non-null assertion operator and usesargvinstead ofargsfor the command line arguments.
409-413: Updated property references in context creation for validation errors testThe context creation for the validation errors test now uses the new property names consistently.
src/definition.ts (5)
17-17: Updated type import to useArgsinstead ofArgOptionsThe import statement now uses the
Argstype from 'args-tokens', aligning with the breaking interface changes.
20-20: Updated re-export to useArgs, ArgSchemainstead ofArgOptions, ArgOptionSchemaThe 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 useA extends Argsinstead of previous typeThe
definefunction now uses the new generic type parameter name and constraint.
37-40: Updated function signature to useA extends Argsin lazy functionThe
lazyfunction now uses the new generic type parameter name and constraint for all parameters.
42-46: Renamed property assignments in lazy function from.optionsto.argsThe property assignments in the
lazyfunction have been updated to use.argsinstead of.optionswhen adding metadata to the loader function.src/types.ts (14)
6-6: Updated type imports to useArgsinstead ofArgOptionsThe import statement now uses the
Argstype from 'args-tokens', aligning with the breaking interface changes.
23-31: UpdatedKeyOfArgOptionstype to useA extends ArgsThe utility type has been renamed from
KeyOfArgOptionsto use the newArgstype parameter, while maintaining the same functionality for extracting keys including negatable boolean options.
66-68: UpdatedCommandOptionKeystype to useA extends ArgsThe utility type now uses the new
Argstype parameter, maintaining the same functionality for generating namespaced option keys.
74-74: UpdatedCommandEnvironmentinterface to useA extends ArgsThe interface now uses the new
Argstype parameter.
134-138: Updated render function signatures inCommandEnvironmentto use new type parameterThe render function types now use the updated
CommandContext<A>with the new type parameter.
142-145: Updated validation errors render function signatureThe validation errors render function type now uses the updated
CommandContext<A>with the new type parameter.
151-151: UpdatedCommandOptionsinterface to useA extends ArgsThe interface now uses the new
Argstype parameter.
200-209: Updated render function signatures inCommandOptionsto use new type parameterThe render function types now use the updated
CommandContext<A>with the new type parameter.
221-245: UpdatedCommandContextinterface to useA extends ArgsThe interface now uses the new
Argstype parameter, and the property has been renamed fromoptionstoargswith updated documentation comments to reflect this change.
285-299: Updated function signatures and type parameters inCommandContextThe
loadCommandsreturn type andtranslatefunction type parameters now use the updatedA extends Argstype parameter.
305-320: UpdatedCommandinterface to useA extends ArgsThe interface now uses the new
Argstype parameter, and the property has been renamed fromoptionstoargswith updated documentation comments to reflect this change.
329-333: Updated function signatures inCommandinterfaceThe
runandresourceproperty types now use the updatedA extends Argstype parameter.
339-359: UpdatedCommandResourceandCommandResourceFetchertypesThese types now use the updated
A extends Argstype parameter, maintaining the same functionality.
421-445: Updated remaining command-related typesThe
CommandRunner,CommandLoader,LazyCommand, andCommandabletypes now use the updatedA extends Argstype parameter.src/utils.ts (5)
8-8: LGTM! Nice update to the imports.The import statement for
Argsfrom '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 ArgOptionstoA extends Argsto align with the new type system from args-tokens.
29-29: Property access update is consistent.Properly renamed property access from
optionstoargsto maintain consistency with the new type naming convention.
45-45: Property access update is consistent.Properly renamed property access from
optionstoargsto maintain consistency with the new type naming convention.
63-67: Generic parameter update is correct.The type signature for
resolveBuiltInKeyhas 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
CommandContextParamsinterface has been correctly updated to useA extends Argsand renamed theoptionsproperty toargs.
65-65: Parameter renamed for clarity.Appropriately renamed from
argstoargvto better distinguish between command-line arguments and the typed argument schema.
89-102: Function signature updated to use new generic type.The
createCommandContextfunction's signature has been correctly updated to useA extends ArgsandV extends ArgValues<A>instead of the previousOptionsandValuestypes.
107-110: Variable and type update is consistent.Properly updated variable from accessing
args as Argsand creating a newArgstype.
158-161: Translation function type parameters updated correctly.The
translatefunction's type parameters have been properly updated to usekeyof Ainstead of the previous type.
181-182: Cached commands type update is consistent.The type for
cachedCommandsand the return type ofloadCommandshave been properly updated to useCommand<A>[].
198-209: Context creation uses correct property names.The context creation now correctly uses
argsinstead ofoptionsand assignsargvto the_property.
222-226: Renamed variable and property access is appropriate.The variable access has been renamed from
optionstoargsand property access updated accordingly.
236-269: Function signatures updated properly.The
loadCommandResourcefunction 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
clifunction signature has been correctly updated to useA extends Argsinstead of the previous type.
90-106: Type parameters and return type properly updated.The
resolveCommandOptionsfunction has been correctly updated to use the new type parameters.
120-129: Function signature properly updated.The
showUsagefunction has been correctly updated to useA extends Argsinstead of the previous type.
131-133: Function signature properly updated.The
showVersionfunction has been correctly updated to useA extends Argsinstead of the previous type.
135-145: Function signature properly updated.The
showHeaderfunction has been correctly updated to useA extends Argsinstead of the previous type.
147-156: Function signature properly updated.The
showValidationErrorsfunction has been correctly updated to useA extends Argsinstead of the previous type.
158-186: Function signature and parameters properly updated.The
resolveCommandfunction has been correctly updated to use the new type parameters.
188-190: Function signature properly updated.The
resolveEntryNamefunction has been correctly updated to useA extends Argsinstead of the previous type.
| 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}` |
There was a problem hiding this comment.
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.
| 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)
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (2)
docs/guide/essentials/declarative-configuration.md (2)
16-18:⚠️ Potential issueNote: Missed property rename in basic structure example
The property name in the basic declarative structure example still uses
optionsinstead ofargs. 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 suggestionUpdate 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 textThe 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 fromoptionstoargs, 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 descriptionThe context object property description has been updated from
optionstoargsto 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
⛔ Files ignored due to path filters (1)
playground/deno/deno.lockis 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: RenamedoptionstoargsThis is part of the PR's intended breaking change to standardize the naming convention for command argument definitions. The rename from
optionstoargsis more appropriate for supporting positional arguments as mentioned in the PR objectives.playground/i18n/index.js (1)
11-11: Breaking change: RenamedoptionstoargsThis 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
runfunction (viactx.values) are unchanged.playground/docs-gen/index.js (1)
9-9: Breaking change: RenamedoptionstoargsThis property rename is consistent with the standardization effort across the codebase to support positional arguments. The implementation details in the
runfunction remain unaffected as arguments are still accessed viactx.values.playground/modularization-lazy-async/commands/bar/meta.js (1)
4-4: Breaking change: RenamedoptionstoargsThis property rename completes the standardization of command argument definitions. The command definition remains functionally identical, with only the property name changing from
optionstoargs.docs/guide/essentials/getting-started.md (1)
70-70: Property name updated to align with the new API.The change from
optionstoargsis 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
optionstoargsis 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
optionstoargsin the createCommand definition aligns with the breaking changes being implemented across the codebase.
34-34: Property name updated for mainCommand definition.The renaming from
optionstoargsin 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
optionstoargsin 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
optionstoargsin the asyncDataDefinition aligns with the breaking changes being introduced to the API.playground/custom-usage/index.js (3)
11-11: Property rename fromoptionstoargslooks goodThis change is part of a breaking change to rename the property for command argument definitions from
optionstoargsthroughout the codebase. The change is consistent with the PR objectives.
102-102: Property reference updated correctlyThe context property reference has been updated from
ctx.optionstoctx.argsto align with the renamed property.
105-105: Object.entries iteration updated correctlyThe iteration over command arguments has been properly updated to use
ctx.argsinstead ofctx.options.playground/auto-usage/index.js (1)
11-12: Comment and property renamed consistentlyBoth the comment describing arguments and the property name have been updated from
optionstoargs. This maintains consistency with the breaking change throughout the codebase.playground/declarative/index.js (2)
12-13: Comment and property renamed consistentlyBoth the comment and property have been updated from "options" to "args", maintaining consistency with the breaking change.
52-52: Console log statement updated correctlyThe console.log statement has been updated to reflect the property rename from
ctx.optionstoctx.args, and the label has been updated from 'Options:' to 'Args:' for consistency.docs/guide/essentials/internationalization.md (2)
23-23: Documentation examples updated consistentlyAll code examples in the internationalization documentation have been updated to use the
argsproperty instead ofoptions. 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:Details
✅ Verification successful
Verify if the
Option:prefix needs to be renamedThe codebase has been updated to rename
optionstoargs, but the translation key prefix remainsOption: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 asOption: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.resolveOptionKeyand its tests insrc/context.test.ts) still expects translation keys to be prefixed withOption:. 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
optionstoargsto 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
optionstoargsin the subcommand example.playground/composable/index.js (4)
10-10: Interface update: renamed 'options' to 'args' in createCommandThe property for defining command arguments has been renamed from
optionstoargsto align with the breaking interface changes.
34-34: Interface update: renamed 'options' to 'args' in listCommandThe property for defining command arguments has been renamed from
optionstoargsto align with the breaking interface changes.
63-63: Interface update: renamed 'options' to 'args' in deleteCommandThe property for defining command arguments has been renamed from
optionstoargsto align with the breaking interface changes.
98-99: Interface update: renamed 'options' to 'args' in mainCommandThe property for defining command arguments has been renamed from
optionstoargsto 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 createCommandConsistent renaming of the command argument definition property from
optionstoargsto align with the breaking interface changes in the Deno TypeScript implementation.
48-48: Interface update: renamed 'options' to 'args' in mainCommandConsistent renaming of the command argument definition property from
optionstoargsto 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 definitionThe property for defining command arguments has been renamed from
optionstoargsto 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 fromoptionstoargsas described in PRThe property has been correctly renamed from
optionstoargsin this command definition, aligning with the breaking change mentioned in the PR objectives.
19-19: Type alias renamed fromHelloOptionstoHelloArgsThe type alias has been properly renamed and its reference to
helloDefinition.argshas been updated to match the new property name.
22-24: Comments updated to reflect new type namingThe documentation comments have been updated to correctly reference the new type naming convention using
HelloArgs.
24-24: Return type updated fromCommandRunner<HelloOptions>toCommandRunner<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 objectThe context parameter type and associated comment have been correctly updated to reflect the new type system.
1-63:Details
✅ 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.
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