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

Bash completion understands options even after "--" #1247

Closed
bertolinocastro opened this issue Mar 1, 2019 · 3 comments · Fixed by #1248
Closed

Bash completion understands options even after "--" #1247

bertolinocastro opened this issue Mar 1, 2019 · 3 comments · Fixed by #1248
Labels
f:completion feature: shell completion
Milestone

Comments

@bertolinocastro
Copy link
Contributor

bertolinocastro commented Mar 1, 2019

Click Bash Completion prints out command's options for any string starting with a single dash even after the double dash separator.

I'm facing this problem because I'm trying to create a wrapper with Click and I would like to use Click's auto completion to print out options from my wrapped program.

So, supposing that I'm wrapping git and my program is called logbuch, my command line would be something like:

logbuch -g -- commit -<TAB>

Supposing I'm doing some workaround in-code to get the git commit's options, I'm returning that as a list of strings from a callback to my command argument autocompletion param. Like this:

@click.argument('arg',nargs=-1,type=click.STRING,autocompletion=auto_comp_callback)

Is there any way to prevent Click from completing my program's options instead of calling my callback? I have read this code and it sounds like that Click does not check for double dashes before calling the start_of_option at line 246.

Besides that, I think that this issue goes in opposite way to this statement at Click docs: " After the -- marker, all further parameters are accepted as arguments."

I'm using python3.7 with Click installed by python3.7 -m pip install click.

@bertolinocastro
Copy link
Contributor Author

bertolinocastro commented Mar 2, 2019

I have commited a fix for this issue on my Click fork.

I'm not doing a pull request since I'm not envolved with Click's development and you guys will certainly do a better fix.

@davidism
Copy link
Member

davidism commented Mar 2, 2019

Please make a PR here. Plenty of community members make PRs, otherwise nothing would ever get fixed.

bertolinocastro added a commit to bertolinocastro/click that referenced this issue Mar 2, 2019
@bertolinocastro
Copy link
Contributor Author

bertolinocastro commented Mar 2, 2019

I just did that. Please, tell me if I need to do anything else.

@davidism davidism reopened this Mar 13, 2019
bertolinocastro added a commit to bertolinocastro/click that referenced this issue Mar 16, 2019
bertolinocastro added a commit to bertolinocastro/click that referenced this issue Mar 16, 2019
bertolinocastro added a commit to bertolinocastro/click that referenced this issue Mar 16, 2019
bertolinocastro added a commit to bertolinocastro/click that referenced this issue Mar 16, 2019
@davidism davidism added this to the 7.1 milestone Feb 27, 2020
@davidism davidism added the f:completion feature: shell completion label Feb 27, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f:completion feature: shell completion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants