show possible choices
This commit is contained in:
parent
639e88262e
commit
bbc3e9d717
1 changed files with 22 additions and 6 deletions
|
@ -66,6 +66,15 @@ def bash_completion():
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
file_metavars = (
|
||||||
|
'FILENAME',
|
||||||
|
'PATH',
|
||||||
|
)
|
||||||
|
|
||||||
|
file_destinations = (
|
||||||
|
'config_paths'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def conditionally_emit_file_completion(action: Action):
|
def conditionally_emit_file_completion(action: Action):
|
||||||
'''
|
'''
|
||||||
|
@ -74,16 +83,23 @@ def conditionally_emit_file_completion(action: Action):
|
||||||
|
|
||||||
Otherwise, return an empty string.
|
Otherwise, return an empty string.
|
||||||
'''
|
'''
|
||||||
if not action.metavar:
|
|
||||||
return ''
|
|
||||||
|
|
||||||
args = ' '.join(action.option_strings)
|
args = ' '.join(action.option_strings)
|
||||||
|
|
||||||
|
if action.metavar in file_metavars or action.dest in file_destinations:
|
||||||
return dedent(
|
return dedent(
|
||||||
f'''
|
f'''
|
||||||
complete -c borgmatic -a '{args}' -Fr -n "__borgmatic_last_arg {args}"'''
|
complete -c borgmatic -a '{args}' -Fr -n "__borgmatic_last_arg {args}"'''
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if action.choices:
|
||||||
|
return dedent(
|
||||||
|
f'''
|
||||||
|
complete -c borgmatic -a '{' '.join(map(str, action.choices))}' -n "__borgmatic_last_arg {args}"'''
|
||||||
|
)
|
||||||
|
|
||||||
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def dedent_strip_as_tuple(string: str):
|
def dedent_strip_as_tuple(string: str):
|
||||||
return (dedent(string).strip("\n"),)
|
return (dedent(string).strip("\n"),)
|
||||||
|
|
Loading…
Reference in a new issue