Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clap_generate an incorrect autocomplete zsh script #2479

Closed
2 tasks done
mothsART opened this issue May 13, 2021 · 9 comments
Closed
2 tasks done

clap_generate an incorrect autocomplete zsh script #2479

mothsART opened this issue May 13, 2021 · 9 comments
Labels
A-completion Area: completion generator C-bug Category: Updating dependencies 💸 $5

Comments

@mothsART
Copy link

Please complete the following tasks

  • I have searched the discussions
  • I have searched the existing issues

Rust Version

rustc 1.53.0-nightly

Clap Version

master

Minimal reproducible code

Hi, I tried to generate on my little project https://github.com/mothsART/pouf autocompletion on zsh.

Cargo build produce this file :
https://github.com/mothsART/pouf/blob/8335f28d5ea9c6a3916a3d5098481e3aaab9f45d/_pouf

and I included with :

source _pouf

This produce an error like :

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

If i manualy delete _pouf "$@", everything seems correct.

Same issue with 2 opposite version of Zsh :
Zsh 5.1 and 5.8 (the last one).

Finally, the script suggest me

compdef _pouf pouf

but it doesn't work.
I replace it with :

compdef _pouf pouf

Steps to reproduce the bug with the above code

cargo build

Actual Behaviour

https://github.com/mothsART/pouf/blob/8335f28d5ea9c6a3916a3d5098481e3aaab9f45d/_pouf

Expected Behaviour

https://github.com/mothsART/pouf/blob/7e464e21f0a46795c83026511980f7c18de27dbb/_pouf

Additional Context

No response

Debug Output

No response

@mothsART mothsART added the C-bug Category: Updating dependencies label May 13, 2021
@pksunkara pksunkara added A-completion Area: completion generator 💸 $5 labels May 13, 2021
@ajeetdsouza
Copy link
Contributor

Finally, the script suggest me

compdef _pouf pouf

but it doesn't work.
I replace it with :

compdef _pouf pouf

You've mentioned the same thing twice. Also, I'm not sure what is incorrect about the script, it works fine for me.

image

@pksunkara
Copy link
Member

It might be a zsh version issue.

@ajeetdsouza
Copy link
Contributor

Perhaps. I'm running zsh 5.8, which appears to be the latest release.

@mothsART
Copy link
Author

  1. I'm using zsh 5.8 too.

  2. the script suggest me (sorry for duplicate) :

#compdef pouf

and not

#compdef _pouf pouf
  1. When I see your screenshot @ajeetdsouza, i think you've cloning my github project and checkout on "master" branch, right ?
    It's not what I report.

I've report a specific commit. (and the solution in the other hand)
Master branch works actually because i have temporaly monkey patch the build process here : https://github.com/mothsART/pouf/blob/master/build.rs#L20

@ajeetdsouza
Copy link
Contributor

Could you share how you're sourcing the completion script? I'm using clap v3 completions in zoxide, and they're working fine on zsh. See my completions file here.

AFAIK, a completion script is sourced by adding the containing folder to $fpath:

fpath=("$HOME/ws/zoxide/contrib/completions" "${fpath[@]}")

@mothsART
Copy link
Author

Like I say on first comment, I used :

source "$HOME_pouf

fpath doesn't work... I guess beacuse error isn't show.

@ajeetdsouza
Copy link
Contributor

ajeetdsouza commented May 21, 2021

Have you called compinit after setting fpath?

autoload -Uz compinit && compinit

I don't think you're supposed to source completions.

@mothsART
Copy link
Author

Hum, right : my autoload is called before my fpath.
Works nice but some documentation would be great : zsh configuration seems not intuitive.

@ajeetdsouza
Copy link
Contributor

Agreed, that's why I created #2488.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion Area: completion generator C-bug Category: Updating dependencies 💸 $5
Projects
None yet
Development

No branches or pull requests

3 participants