TeXitoi / structopt

Parse command line arguments by defining a struct.
Other
2.71k stars 151 forks source link

Error using completions in zsh #461

Closed MrDogeBro closed 3 years ago

MrDogeBro commented 3 years ago

When trying to generate completions for my cli, I get this error every time zsh loads. Weird thing though is that if I tell it to use bash and not zsh completions, it works just fine and completions work, etc. I am using oh-my-zsh if that would affect it in any way. Any help/explanations would be greatly appreciated.

Error:

_arguments:comparguments:312: can only be called from completion function

Code:

Quicknav::clap().gen_completions_to("quicknav", Shell::Zsh, &mut std::io::stdout());
TeXitoi commented 3 years ago

You'll have to ask to clap, as .get_completions_to is a clap function, and give more information to be able to reproduce the bug (as the Quicknav struct with structopt annotations)

TeXitoi commented 3 years ago

Also, it looks like a function is used in a wrong context, are you sure you call the script correctly? (I don't know anything about zsh)

gakonst commented 2 years ago

For anyone bumping on this issue, here's the relevant Clap ones:

And how to config compinit in zsh https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#telling-zsh-which-function-to-use-for-completing-a-command