mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-22 15:28:57 +00:00
accept names of other commands in help command
This commit is contained in:
parent
8a1ebe0112
commit
f47353e7ef
1 changed files with 11 additions and 7 deletions
|
@ -2,6 +2,7 @@
|
||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
import functools
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
|
@ -385,13 +386,15 @@ def do_prune(self, args):
|
||||||
$ attic create -e /home/user/cache/ repo.attic / /home/user/cache/important
|
$ attic create -e /home/user/cache/ repo.attic / /home/user/cache/important
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def do_help(self, args):
|
def do_help(self, parser, commands, args):
|
||||||
if args.topic in self.helptext:
|
if not args.topic:
|
||||||
|
parser.print_help()
|
||||||
|
elif args.topic in self.helptext:
|
||||||
print(self.helptext[args.topic])
|
print(self.helptext[args.topic])
|
||||||
|
elif args.topic in commands:
|
||||||
|
commands[args.topic].print_help()
|
||||||
else:
|
else:
|
||||||
# FIXME: If topic is one of the regular commands, show that help.
|
parser.error('No help available on %s' % (args.topic,))
|
||||||
# Otherwise, show the default global help.
|
|
||||||
print('No help available on %s' % (args.topic,))
|
|
||||||
return self.exit_code
|
return self.exit_code
|
||||||
|
|
||||||
def preprocess_args(self, args):
|
def preprocess_args(self, args):
|
||||||
|
@ -619,8 +622,9 @@ def run(self, args=None):
|
||||||
|
|
||||||
subparser = subparsers.add_parser('help', parents=[common_parser],
|
subparser = subparsers.add_parser('help', parents=[common_parser],
|
||||||
description='Extra help')
|
description='Extra help')
|
||||||
subparser.set_defaults(func=self.do_help)
|
subparser.set_defaults(
|
||||||
subparser.add_argument('topic', metavar='TOPIC', type=str,
|
func=functools.partial(self.do_help, parser, subparsers.choices))
|
||||||
|
subparser.add_argument('topic', metavar='TOPIC', type=str, nargs='?',
|
||||||
help='additional help on TOPIC')
|
help='additional help on TOPIC')
|
||||||
|
|
||||||
args = parser.parse_args(args or ['-h'])
|
args = parser.parse_args(args or ['-h'])
|
||||||
|
|
Loading…
Reference in a new issue