Add fish completions - #1153
Open
Vincent-Carrier wants to merge 1 commit into
Open
Add fish completions#1153Vincent-Carrier wants to merge 1 commit into
Vincent-Carrier wants to merge 1 commit into
Conversation
Delegates to `xan compgen` like the bash and zsh scripts. The word before the cursor selects the completion mode, so it is passed verbatim where that works, notably for the flags whose value is a column selector (-s/--select, -g/--groupby). It does not work on `xan select file.csv <TAB>`, where that word is the file name rather than the subcommand, so the subcommand is used as a fallback when the literal word matches nothing. No -f on the complete, so that fish keeps completing file names when compgen returns nothing, mirroring `-o default` in bash and `_default` in zsh.
| # subcommand, so fall back to the subcommand when it matches nothing. | ||
| set -l previous $tokens[-1] | ||
|
|
||
| if not contains -- $previous -s --select -g --groupby |
Member
There was a problem hiding this comment.
Why is this required? This looks like a repetition of xan compgen inner logic, no?
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.
Closes #1152.
Adds a
fisharm toxan completions, alongsidebashandzsh.Like the two existing scripts, the fish function delegates everything to
xan compgen <cmd> <current> <previous>and implements no completion logic of its own, so all three shells trackcompgen.rstogether.Two details are fish-specific, both covered in the issue:
<previous>is passed verbatim where that works — notably the flags whose value is a column selector (-s,--select,-g,--groupby), whichcompgenmatches by name. It falls back to the subcommand forxan select file.csv <TAB>, where the literal preceding word is the file name and so matches nothing. The fallback is conditional so it doesn't shadow the flags.-fon thecomplete, so fish keeps completing file names whencompgenreturns nothing — mirroring-o defaultin bash and_defaultin zsh. With-f,xan count <TAB>offered nothing at all.Also updates the
completionsusage text, the README install section, and the changelog.Testing
cargo build,cargo fmtandcargo clippyare clean, and./scripts/docs.shproduces no changes (completionshas no generated page).The generated script was installed and driven with
complete -Cagainst real CSVs, exercising: subcommand listing, prefix filtering (xan se→search/select), columns with and without an explicit file, per-file column resolution across two CSVs, comma-separated selectors (name,ag→name,age),-s/--selectvalues, subcommand groups (xan help), and file-name fallback.