Completion for conda, the package manager - #4837
Conversation
| # Complete using -n to select the given conda subcommand | ||
| # and passing the rest of the arguments to `complete` | ||
| # The goal here is to reduce clutter in the definitions below | ||
| # This function will be deleted at the end |
There was a problem hiding this comment.
That's probably not fantastic since the name is so generic.
If the user has a function with that name, you'll first redefine and then delete it.
|
|
||
| # Option name | ||
| for cmd in create install list remove search update | ||
| if test $cmd = create |
There was a problem hiding this comment.
Move create out of the for-loop since there's no shared part.
| function __fish_conda_needs_command -a cmd | ||
| # We need to filter out -x and --xx options so as to complete | ||
| # the arguments of said options | ||
| test (string match -r '^\w+' -- (commandline -opc))[-1] = $cmd |
There was a problem hiding this comment.
I'd be really careful with test - it has some surprisingly sharp edges. This'll fail when the command substitution returns nothing, and it effectively does the same thing __fish_use_subcommand does.
We do have __fish_seen_subcommand_from, which just tests if a given word has been given. Usually I'll do not __fish_seen_subcommand_from $allcmds (where $allcmds contains all the subcommands that the command accepts).
That's still not perfect, because it'll see something like git -C log as using the "log" subcommand instead of the argument to the "-C" option. To do it properly, you need to actually know which options accept arguments - see how the git or systemctl completions do it - kinda complicated, right?
And treat the case of the first argument as a special case with function __fish_conda_fist_arg
|
Nice, merged! |
I propose completion for the package manager conda. Since fish ships with support for completing
brew,pacaur,pip, etc, I think it is appropriate to also include the rather popularconda.