mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-22 14:11:27 +00:00
support common options on mid-level commands (borg *key* export)
This commit is contained in:
parent
d5edb011f0
commit
2ab5df0217
1 changed files with 8 additions and 4 deletions
|
@ -1904,7 +1904,7 @@ class CommonOptions:
|
||||||
# From lowest precedence to highest precedence:
|
# From lowest precedence to highest precedence:
|
||||||
# An option specified on the parser belonging to index 0 is overridden if the
|
# An option specified on the parser belonging to index 0 is overridden if the
|
||||||
# same option is specified on any parser with a higher index.
|
# same option is specified on any parser with a higher index.
|
||||||
SUFFIX_PRECEDENCE = ('_maincommand', '_subcommand')
|
SUFFIX_PRECEDENCE = ('_maincommand', '_midcommand', '_subcommand')
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
@ -2040,6 +2040,10 @@ def resolve(self, args: argparse.Namespace): # Namespace has "in" but otherwise
|
||||||
common_parser.set_defaults(paths=[], patterns=[])
|
common_parser.set_defaults(paths=[], patterns=[])
|
||||||
parser.common_options.add_common_group(common_parser, '_subcommand')
|
parser.common_options.add_common_group(common_parser, '_subcommand')
|
||||||
|
|
||||||
|
mid_common_parser = argparse.ArgumentParser(add_help=False, prog=self.prog)
|
||||||
|
mid_common_parser.set_defaults(paths=[], patterns=[])
|
||||||
|
parser.common_options.add_common_group(mid_common_parser, '_midcommand')
|
||||||
|
|
||||||
subparsers = parser.add_subparsers(title='required arguments', metavar='<command>')
|
subparsers = parser.add_subparsers(title='required arguments', metavar='<command>')
|
||||||
|
|
||||||
serve_epilog = process_epilog("""
|
serve_epilog = process_epilog("""
|
||||||
|
@ -2221,7 +2225,7 @@ def resolve(self, args: argparse.Namespace): # Namespace has "in" but otherwise
|
||||||
help='work slower, but using less space')
|
help='work slower, but using less space')
|
||||||
self.add_archives_filters_args(subparser)
|
self.add_archives_filters_args(subparser)
|
||||||
|
|
||||||
subparser = subparsers.add_parser('key', parents=[common_parser], add_help=False,
|
subparser = subparsers.add_parser('key', parents=[mid_common_parser], add_help=False,
|
||||||
description="Manage a keyfile or repokey of a repository",
|
description="Manage a keyfile or repokey of a repository",
|
||||||
epilog="",
|
epilog="",
|
||||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||||
|
@ -3221,7 +3225,7 @@ def resolve(self, args: argparse.Namespace): # Namespace has "in" but otherwise
|
||||||
in case you ever run into some severe malfunction. Use them only if you know
|
in case you ever run into some severe malfunction. Use them only if you know
|
||||||
what you are doing or if a trusted developer tells you what to do.""")
|
what you are doing or if a trusted developer tells you what to do.""")
|
||||||
|
|
||||||
subparser = subparsers.add_parser('debug', parents=[common_parser], add_help=False,
|
subparser = subparsers.add_parser('debug', parents=[mid_common_parser], add_help=False,
|
||||||
description='debugging command (not intended for normal use)',
|
description='debugging command (not intended for normal use)',
|
||||||
epilog=debug_epilog,
|
epilog=debug_epilog,
|
||||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||||
|
@ -3362,7 +3366,7 @@ def resolve(self, args: argparse.Namespace): # Namespace has "in" but otherwise
|
||||||
|
|
||||||
benchmark_epilog = process_epilog("These commands do various benchmarks.")
|
benchmark_epilog = process_epilog("These commands do various benchmarks.")
|
||||||
|
|
||||||
subparser = subparsers.add_parser('benchmark', parents=[common_parser], add_help=False,
|
subparser = subparsers.add_parser('benchmark', parents=[mid_common_parser], add_help=False,
|
||||||
description='benchmark command',
|
description='benchmark command',
|
||||||
epilog=benchmark_epilog,
|
epilog=benchmark_epilog,
|
||||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||||
|
|
Loading…
Reference in a new issue