Skip to content

Conversation

@christerswahn
Copy link
Collaborator

@christerswahn christerswahn commented Oct 21, 2025

Renamed the completion subcommands' --target option to --tool. "Tool" is more intuitive since it is actually the tool that is selected, and "target" could be confusing when also specifying file/dir to write to.

Although this is a breaking change since the option name changes, it is good to change while this is a recently added feature, and most uses use the shorthand -t which is unchanged.

Summary by CodeRabbit

  • Refactor

    • Renamed completion option and related fields from "target" to "tool" (e.g., --target → --tool) and aligned generated filenames/labels accordingly.
    • Replaced the previous completion enum/record with a tool-based enum and corresponding script record.
  • Documentation

    • Updated help text, comments, and generated output to reference "tool" instead of "target".
  • Tests

    • Updated tests and generated snippets to use the new "tool" terminology and enum values.

@coderabbitai
Copy link

coderabbitai bot commented Oct 21, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The PR renames the completion API concept from CompletionTarget to CompletionTool across the cli_tools package: enum/typedef replacements, updated imports/exports, option/argument renames (target → tool), example updates, and test adjustments. No control-flow or runtime behavior changes.

Changes

Cohort / File(s) Summary
Examples
packages/cli_tools/example/command_completion_example.dart, packages/cli_tools/example/completion_script_carapace.dart, packages/cli_tools/example/completion_script_completely.dart
Documentation and example code updated to import/use CompletionTool and rename parameters from target to tool in embedded completion script definitions.
Core API migration
packages/cli_tools/lib/src/better_command_runner/completion/completion_tool.dart, packages/cli_tools/lib/src/better_command_runner/completion/completion_target.dart
completion_target.dart removed; new completion_tool.dart added with enum CompletionTool { completely, carapace } and typedef CompletionScript = ({CompletionTool tool, String script}).
Exports / runner wiring
packages/cli_tools/lib/src/better_command_runner/better_command_runner.dart, packages/cli_tools/lib/src/better_command_runner/completion/completion.dart
Updated exports/imports to reference completion_tool.dart instead of completion_target.dart.
Completion command options & logic
packages/cli_tools/lib/src/better_command_runner/completion/completion_command.dart, packages/cli_tools/lib/src/better_command_runner/completion/completion_generate_command.dart, packages/cli_tools/lib/src/better_command_runner/completion/completion_embed_command.dart, packages/cli_tools/lib/src/better_command_runner/completion/completion_install_command.dart
Renamed options and enum usages from targettool (e.g., targetOptiontoolOption); switched references from CompletionTarget to CompletionTool; updated generated file names, metadata, and internal mapping keys to use tool.
Tests
packages/cli_tools/test/better_command_runner/completion_test.dart
All tests updated to import/show CompletionTool, use CompletionTool.* values, and adjust expected strings/YAML from target to tool.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • SandPod
  • nielsenko

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "refactor(cli_tools)!: Renamed 'target' option to 'tool'" directly and accurately describes the primary change in the changeset. The raw summary confirms that the main modification across all modified files is the systematic renaming of the target concept to tool, including the CompletionTarget enum to CompletionTool, the --target option to --tool, parameter names, and all related references throughout the codebase. The title is concise, specific, and uses meaningful language that clearly conveys the breaking change nature (indicated by the ! prefix) without vague or misleading terms. A teammate scanning the project history would immediately understand that this PR renamed an option from target to tool.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 634f4e0 and 789986a.

📒 Files selected for processing (1)
  • packages/cli_tools/example/command_completion_example.dart (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@christerswahn christerswahn changed the title refactor(cli_tools)!: Renamed 'target' option to ' tool refactor(cli_tools)!: Renamed 'target' option to 'tool' Oct 21, 2025
@christerswahn christerswahn marked this pull request as ready for review October 21, 2025 18:44
Copy link

@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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 904a8f0 and 634f4e0.

📒 Files selected for processing (12)
  • packages/cli_tools/example/command_completion_example.dart (1 hunks)
  • packages/cli_tools/example/completion_script_carapace.dart (1 hunks)
  • packages/cli_tools/example/completion_script_completely.dart (4 hunks)
  • packages/cli_tools/lib/src/better_command_runner/better_command_runner.dart (1 hunks)
  • packages/cli_tools/lib/src/better_command_runner/completion/completion.dart (1 hunks)
  • packages/cli_tools/lib/src/better_command_runner/completion/completion_command.dart (1 hunks)
  • packages/cli_tools/lib/src/better_command_runner/completion/completion_embed_command.dart (5 hunks)
  • packages/cli_tools/lib/src/better_command_runner/completion/completion_generate_command.dart (3 hunks)
  • packages/cli_tools/lib/src/better_command_runner/completion/completion_install_command.dart (4 hunks)
  • packages/cli_tools/lib/src/better_command_runner/completion/completion_target.dart (0 hunks)
  • packages/cli_tools/lib/src/better_command_runner/completion/completion_tool.dart (1 hunks)
  • packages/cli_tools/test/better_command_runner/completion_test.dart (8 hunks)
💤 Files with no reviewable changes (1)
  • packages/cli_tools/lib/src/better_command_runner/completion/completion_target.dart
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-07T07:55:17.269Z
Learnt from: christerswahn
PR: serverpod/cli_tools#57
File: packages/config/test/better_command_runner/default_flags_test.dart:1-1
Timestamp: 2025-08-07T07:55:17.269Z
Learning: In the `config` package, `better_command_runner.dart` is intentionally kept as a separate import (`package:config/better_command_runner.dart`) rather than being re-exported through the main `packages/config/lib/config.dart` barrel file. This separation is by design according to the package maintainer christerswahn.

Applied to files:

  • packages/cli_tools/lib/src/better_command_runner/completion/completion.dart
  • packages/cli_tools/lib/src/better_command_runner/better_command_runner.dart
🔇 Additional comments (20)
packages/cli_tools/lib/src/better_command_runner/better_command_runner.dart (1)

9-9: LGTM! Clean import update.

The import path correctly references the new completion_tool.dart file while maintaining the CompletionScript export. This aligns with the broader refactoring effort.

packages/cli_tools/lib/src/better_command_runner/completion/completion.dart (1)

1-1: LGTM! Export correctly updated.

The export now references completion_tool.dart, maintaining the public API surface while aligning with the renamed module.

packages/cli_tools/lib/src/better_command_runner/completion/completion_tool.dart (1)

1-6: LGTM! Clean API definition.

The new CompletionTool enum and CompletionScript typedef are well-defined. The rename from target to tool provides clearer semantics about the purpose of this option.

packages/cli_tools/lib/src/better_command_runner/completion/completion_command.dart (2)

9-9: LGTM! Import correctly updated.

The import now references the new completion_tool.dart module.


12-23: LGTM! Option definition properly refactored.

The rename from targetOption to toolOption is consistent throughout, with appropriate updates to the argument name and help text. The preservation of the -t abbreviation minimizes the impact of this breaking change on users who rely on the shorthand.

packages/cli_tools/example/completion_script_completely.dart (3)

4-4: LGTM! Import updated correctly.

The import now shows CompletionTool instead of the old CompletionTarget.


63-100: LGTM! Embedded completion script updated consistently.

The bash completion script has been properly regenerated to reference --tool instead of --target throughout all completion cases. This ensures users get accurate completions for the renamed option.


117-117: LGTM! Record field renamed correctly.

The record now uses tool: CompletionTool.completely instead of the old target: field name, consistent with the API refactor.

packages/cli_tools/example/completion_script_carapace.dart (3)

4-4: LGTM! Import updated correctly.

The import now shows CompletionTool instead of CompletionTarget.


10-34: LGTM! Embedded carapace specification updated consistently.

The YAML specification has been properly regenerated with all references to target replaced with tool, including flag definitions and completion mappings. This ensures carapace will provide accurate completions for the renamed option.


42-42: LGTM! Record field renamed correctly.

The record now uses tool: CompletionTool.carapace, matching the new API surface.

packages/cli_tools/lib/src/better_command_runner/completion/completion_generate_command.dart (4)

10-10: LGTM! Import updated correctly.

The import now references completion_tool.dart.


14-14: LGTM! Enum value renamed consistently.

The enum value is now tool and correctly references CompletionOptions.toolOption.


41-41: LGTM! Variable and config access updated.

The variable is now named tool and retrieves the correct option value.


58-65: LGTM! Switch statement updated to use new enum.

The switch cases now correctly reference CompletionTool.completely and CompletionTool.carapace.

packages/cli_tools/test/better_command_runner/completion_test.dart (3)

93-93: LGTM! Test assertions updated correctly.

The test expectations now verify that generated specifications reference --tool instead of --target, ensuring the refactor is working as intended.

Also applies to: 129-129, 163-163, 168-168


235-235: LGTM! Embedded script generation tests updated.

The tests verify that embedded scripts are generated with the correct import (CompletionTool) and record field name (tool:), ensuring consistency across the public API.

Also applies to: 250-250, 290-290, 302-302


337-337: LGTM! Test data uses new enum correctly.

The test data now uses CompletionTool.completely and CompletionTool.carapace, matching the refactored API.

Also applies to: 341-341

packages/cli_tools/lib/src/better_command_runner/completion/completion_embed_command.dart (1)

13-13: LGTM! Clean and consistent refactor from target to tool.

The rename is systematic and complete throughout this file:

  • Enum value correctly references CompletionOptions.toolOption
  • File naming template updated to use <tool> placeholder
  • Runtime configuration reads use tool consistently
  • Generated code template correctly imports CompletionTool and uses tool in all references

Also applies to: 25-25, 64-67, 98-98, 116-116, 122-124

packages/cli_tools/lib/src/better_command_runner/completion/completion_install_command.dart (1)

10-10: LGTM! Thorough and consistent refactor.

The refactor is complete and well-executed:

  • Import updated to completion_tool.dart
  • Type signatures updated (Map<CompletionTool, String>)
  • Constructor correctly maps e.tool instead of e.target
  • All runtime references use tool consistently
  • Error messages use the new "tool" terminology
  • Switch expressions correctly reference CompletionTool.completely and CompletionTool.carapace

Also applies to: 13-13, 30-30, 35-35, 48-48, 59-61, 67-85

Copy link
Contributor

@nielsenko nielsenko left a comment

Choose a reason for hiding this comment

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

I agree, and the down stream dependencies are still few. Go for it 🐰

Had just one comment on a comment.. Nittiest of nits. Feel free to disregard.

@christerswahn christerswahn merged commit 974a3cf into main Oct 22, 2025
9 of 10 checks passed
@christerswahn christerswahn deleted the complet-improv branch October 22, 2025 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants