-
Notifications
You must be signed in to change notification settings - Fork 34
Add autocompletion callback for Options #27
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,10 @@ def get_choices(cli, prog_name, args, incomplete): | |
break | ||
choices = [] | ||
if optctx: | ||
choices += [c if isinstance(c, tuple) else (c, None) for c in optctx.type.complete(ctx, incomplete)] | ||
choices += [c if isinstance(c, tuple) else(c, None) for c in optctx.type.complete(ctx, incomplete)] | ||
if not choices and hasattr(optctx, 'autocompletion') and optctx.autocompletion is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so it means that the choices provided by the type have the precedence over the autocompletion provided by the user. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's the order in the Realistically I guess you shouldn't be using both. But certainly for |
||
dynamic_completions = optctx.autocompletion(ctx=ctx, args=args, incomplete=incomplete) | ||
choices += [c if isinstance(c, tuple) else (c, None) for c in dynamic_completions] | ||
else: | ||
for param in ctx.command.get_params(ctx): | ||
if (completion_configuration.complete_options or incomplete and not incomplete[:1].isalnum()) and isinstance(param, Option): | ||
|
Uh oh!
There was an error while loading. Please reload this page.