rename function

This commit is contained in:
Isaac 2023-05-04 21:14:48 -07:00
parent bbc3e9d717
commit 193731a017
No known key found for this signature in database
GPG key ID: E69FB5A841448A48

View file

@ -66,20 +66,20 @@ def bash_completion():
)
)
file_metavars = (
'FILENAME',
'PATH',
)
file_destinations = (
'config_paths'
)
file_destinations = '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
if the action takes a file argument and was the last action on the command line.
Given an argparse.Action instance, return a completion invocation
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.
'''
@ -157,13 +157,13 @@ def fish_completion():
)
+ ('\n# global flags',)
+ 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
if len(action.option_strings) > 0
)
+ ('\n# subparser flags',)
+ 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 in subparser._actions
)