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

add support for custom bash completers and choices #643

Closed
wants to merge 1 commit into from

Conversation

ericfrederich
Copy link
Contributor

After writing this I noticed #428 which mentioned #241 but thought I'd submit this pull request anyway.

This one uses completer and choices as keyword arguments using the same terminology as argcomplete

Dunno how hacky this is, but I got it to work for me. I basically pass some more context (the last parsed argument) to get_choices which it uses to look up either completer or choices attributes on the option.

@ericfrederich
Copy link
Contributor Author

updated now with passing tests; added some tests for this new feature too

if last_complete in param.opts:
if param.completer is not None:
choices.extend(str(c) for c in param.completer())
if param.choices is not None:

This comment was marked as off-topic.

@untitaker
Copy link
Contributor

I suspect this command is slightly buggy when completing a option with = like --local-opt=.

@ericfrederich
Copy link
Contributor Author

@untitaker This patch should fix all the issues you mentioned with the previous one.

@untitaker
Copy link
Contributor

Could you add a testcase that uses --local-opt=value instead of --local-opt value? As said I suspect that there's a bug in your code with invocations such
as:

cli subcommand --local-opt=<tab><tab>

Thanks!

On Thu, Sep 01, 2016 at 01:28:14PM -0700, Eric L. Frederich wrote:

@untitaker This patch should fix all the issues you mentioned with the previous one.

You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#643 (comment)

@ericfrederich
Copy link
Contributor Author

@untitaker as I'm getting more familiar with Click's internals I'm going to close this request and do a better implementation later... hopefully soon!

@untitaker
Copy link
Contributor

Okay cool. Feel free to email me if you're unclear about something.

@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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants