Repository navigation
fix: use fish long options for multi-character flag names - #2453
Open
SulimanAbdulrazzaq wants to merge 1 commit into
Open
SulimanAbdulrazzaq wants to merge 1 commit into
SulimanAbdulrazzaq wants to merge 1 commit into
Conversation
fish reads the argument of complete -s as a group of one-character options. The fish completion generator wrote every name after the first as -s and the first name as -l, so an alias such as fl became the options f and l instead of --fl, and a one-character name was registered as --o. Write a name as -s only when it is a single character and as -l otherwise.
|
This branch has not been deployed
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.
What type of PR is this?
What this PR does / why we need it:
ToFishCompletionwrites the first name of a flag as-land every other name as-s. fish reads the argument ofcomplete -sas a group of one-character options, so an alias with more than one character is registered as several unrelated short options instead of one long option, and a one-character first name is registered as a long option.For
Name: "verbose", Aliases: []string{"loud", "v"}the generated line was-l verbose -s loud -s v. With fish 3.7.0 on the old output,complete -C 'greet --lo'returns nothing andcomplete -C 'greet -l'offers-ld -lo -lp -lt -lu -lv. ForName: "o", Aliases: []string{"output", "out"}the old output registered--oand the short optionso,u,t,p.The generator now uses
-sfor a one-character name and-lfor any other name, whichever position it has in the flag's names. With the change,complete -C 'greet --lo'returns--loudandcomplete -C 'greet --ou'returns--outand--output.fish.go: choose-sor-lper name.testdata/expected-fish-full.fish: theflandsub-flaliases are now-l fland-l sub-fl.fish_test.go: newTestFishCompletionShortAndLongNames.Which issue(s) this PR fixes:
NONE
Special notes for your reviewer:
Not changed on purpose: command aliases are still not offered by the fish completion, and the bash, zsh and PowerShell scripts do not use these options. Flags whose names are all one character, or whose aliases are all one character (the existing help golden file), generate the same output as before.
Testing
make lint,make vet,make test,make test GFLAGS='--tags urfave_cli_no_template',make generate,make diffcheckandmake v3diffpass in a fork run on ubuntu. The new test fails without the change and passes with it. A fork step also sources the generated script in fish 3.7.0 and runscomplete -Cas described above.Release Notes