rename function
This commit is contained in:
parent
bbc3e9d717
commit
193731a017
1 changed files with 9 additions and 9 deletions
|
@ -66,20 +66,20 @@ def bash_completion():
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
file_metavars = (
|
file_metavars = (
|
||||||
'FILENAME',
|
'FILENAME',
|
||||||
'PATH',
|
'PATH',
|
||||||
)
|
)
|
||||||
|
|
||||||
file_destinations = (
|
file_destinations = 'config_paths'
|
||||||
'config_paths'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def conditionally_emit_file_completion(action: Action):
|
def conditionally_emit_arg_completion(action: Action):
|
||||||
'''
|
'''
|
||||||
Given an argparse.Action instance, return a completion invocation that forces file completion
|
Given an argparse.Action instance, return a completion invocation
|
||||||
if the action takes a file argument and was the last action on the command line.
|
that forces file completion or options completion, if the action
|
||||||
|
takes such an argument and was the last action on the command line.
|
||||||
|
|
||||||
Otherwise, return an empty string.
|
Otherwise, return an empty string.
|
||||||
'''
|
'''
|
||||||
|
@ -157,13 +157,13 @@ def fish_completion():
|
||||||
)
|
)
|
||||||
+ ('\n# global flags',)
|
+ ('\n# global flags',)
|
||||||
+ tuple(
|
+ tuple(
|
||||||
f'''complete -c borgmatic -f -a '{' '.join(action.option_strings)}' -d {shlex.quote(action.help)}{conditionally_emit_file_completion(action)}'''
|
f'''complete -c borgmatic -f -a '{' '.join(action.option_strings)}' -d {shlex.quote(action.help)}{conditionally_emit_arg_completion(action)}'''
|
||||||
for action in top_level_parser._actions
|
for action in top_level_parser._actions
|
||||||
if len(action.option_strings) > 0
|
if len(action.option_strings) > 0
|
||||||
)
|
)
|
||||||
+ ('\n# subparser flags',)
|
+ ('\n# subparser flags',)
|
||||||
+ tuple(
|
+ tuple(
|
||||||
f'''complete -c borgmatic -f -a '{' '.join(action.option_strings)}' -d {shlex.quote(action.help)} -n "__fish_seen_subcommand_from {action_name}"{conditionally_emit_file_completion(action)}'''
|
f'''complete -c borgmatic -f -a '{' '.join(action.option_strings)}' -d {shlex.quote(action.help)} -n "__fish_seen_subcommand_from {action_name}"{conditionally_emit_arg_completion(action)}'''
|
||||||
for action_name, subparser in subparsers.choices.items()
|
for action_name, subparser in subparsers.choices.items()
|
||||||
for action in subparser._actions
|
for action in subparser._actions
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue