Repository navigation
feat: wt <worktree> is short for wt cd <worktree> - #2
Merged
Merged
Conversation
`wt cd <worktree>` is verbose for the command you type most often, so an unknown first word is now a worktree name. Clap gives that word to an external subcommand, and it reaches the same lookup as `wt cd`, so a branch name and the start of a directory name work in the short form as well. A command wins over a worktree with the same name, because clap reads the first word as a command before anything else. `wt ls` therefore prints the worktrees also when a worktree has the name ls, and the long form `wt cd ls` reaches that worktree. `wt add` prints a warning when it makes a directory with the name of a command. The list of commands comes from clap itself, so it cannot drift. A word that is neither gives one message for both, so a mistyped command does not read as a missing worktree. The fish function now names the commands that write for the user, and reads a path from every other word. The binary therefore decides what is a worktree, and a worktree name completes in the position of a command.
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.
wt cd <worktree>is verbose for the command you type most often, so an unknown first word is now a worktree name. It reaches the same lookup aswt cd, so a branch name and the start of a directory name work in the short form as well.Collisions. A command wins over a worktree with the same name, because clap reads the first word as a command before anything else.
wt lstherefore prints the worktrees also when a worktree has the namels, and the long formwt cd lsreaches that worktree. Three things keep the rule visible:wt addprints a warning when it makes a directory with the name of a command. The list of commands comes from clap itself, so it cannot drift.there is no command or worktree with the name snyc.wt --helpnames the short form, andwt help cdgives the rule.Shell. The fish function now names the commands that write for the user, and reads a path from every other word. The binary therefore decides what is a worktree. A worktree name also completes in the position of a command.
Tested in a throwaway repository: the short form, a branch name, a prefix, a worktree with the name
ls, a mistyped command, and the fish function on each of them.