You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Below: shell command w/ optional arg to filter items to a subset of results
FILES= ["entry_aaa.sh", "entry_aab.py", "entry_baa.rb", "entry_bab.sh"]
deffiles_complete(ctx, param, incomplete):
# how to access --name's arguments to filter `FILES` when completion happens?# files = [val for val in FILES if NAME in val]files= [valforvalinFILESifval.startswith(incomplete)]
returnfilescli=Command(
"cli",
params=[
Argument(["PATTERNS"]),
Argument(["FILE"], nargs=-1, shell_complete=files_complete),
Argument(["--name"]),
],
)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When referring to shell completions's
click.ParamType.shell_complete
, is it possible to access sibling argument values?Below: shell command w/ optional arg to filter items to a subset of results
cli_app [FILE...]
cli_app --name [PATTERNS_FILE] [FILE...]
Works fine
cli_app
[tab]cli_app entry_
[tab]>>> pyentry_aaa.sh entry_aab.py entry_baa.rb entry_bab.sh
Problematic case
cli_app --name '.py'
[tab]>>> entry_aaa.sh entry_aab.py
files_complete()
(click.ParamType.shell_complete
) needs to access--name
's args to refine the completion items. Can the click API do that?Beta Was this translation helpful? Give feedback.
All reactions