refactor: unify git-daft and daft command routing#123
Merged
Conversation
Make `git daft <subcommand>` fully equivalent to `daft <subcommand>` by merging the two separate dispatch arms into one. This eliminates the need to add new commands in two places. - Combine "git-daft" and "daft" match arms in main.rs using or-pattern - Extend --version check to also handle git-daft invocation - Update get_clap_args() to handle "git-daft" program name for worktree subcommands - Remove GIT_DAFT_SUBCOMMANDS constant and associated tests from suggest.rs - Derive error label from resolved name for correct "git daft" vs "daft" messaging Fixes #122 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
git-daftanddaftdispatch arms inmain.rsinto a single"git-daft" | "daft"match arm, so adding new subcommands only requires updating one placeget_clap_args()inlib.rsto handle"git-daft"as a program name, enablinggit daft worktree-checkoutand similar worktree subcommandsGIT_DAFT_SUBCOMMANDSconstant and its associated tests fromsuggest.rs--versionflag to work for bothdaft --versionandgit daft --versionFixes #122
Test plan
cargo fmt -- --checkpassescargo clippy -- -D warningspasses with zero warningsjust test-unitpasses (133 tests, 0 failures)git daft hooks status,git daft --version,git daft completions --help,git daft unknown-cmd(should suggest)🤖 Generated with Claude Code