conda-incubator / conda-zsh-completion

zsh completion for conda

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some bugs when completing -h and -V

huyz-git opened this issue · comments

When type conda - and press tab, my terminal shows these:

$ conda -
--help                                                                                                 
--version                                                                                              
-h                                                                                                     
-V                                                                                                     
-- show this help message and exit                                                                     
-- show programs version number and exit                                                               
--help                                                                                                 
--version                                                                                              
-h                                                                                                     
-V                                                                                                     
-- show this help message and exit                                                                     
-- show programs version number and exit                                                               
--help                                                                                                 
--version                                                                                              
-h                                                                                                     
-V                                                                                                     
-- show this help message and exit                                                                     
-- show programs version number and exit

I uses oh-my-zsh to manage this plugin.

@huyizheng thanks for reporting this and thanks for using this completion. I am not sure how you ended up in this situation and I don't see an easy way to debug this. I will however leave this issue open however in case anyone else experiences this too or maybe even has a fix.

@huyizheng thanks for reporting this and thanks for using this completion. I am not sure how you ended up in this situation and I don't see an easy way to debug this. I will however leave this issue open however in case anyone else experiences this too or maybe even has a fix.

I fixed this bug, it seems cause by the line : :->command. (But I don't know why)
I just changed it into this, directly passes the function into the arguments:

_arguments -C $opts \
           ': :__conda_commands' \
           '*:: :->subcmd'

then this bugs is fixed.

Also, in the completion of conda env there's a similar bug, to fix it I create another function like this:

_env_command() {
    local -a env
    env=(
        create:'Create an environment based on an environment file'
        export:'Export a given environment'
        list:'List the Conda environments'
        remove:'Remove an environment'
        update:'Update the current environment based on environment file'
        )
    _describe -t env_commands "help commands"  env
}

And then directly passes it into the arguments:

    (env)
        _arguments -C $help_opts \
                      ': :_env_command' \
                      '*:: :->subcmd'

diff.txt

@huyz-git thank you for looking into this. Could you submit this as a pull-request, it will make testing and integration much easier, thank you!