1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-03-15 00:21:56 +00:00

Merge remote-tracking branch 'jdchristensen/help'

This commit is contained in:
Jonas Borgström 2014-02-09 20:30:57 +01:00
commit 14dd0414eb

View file

@ -351,6 +351,45 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
archive.delete(cache) archive.delete(cache)
return self.exit_code return self.exit_code
helptext = {}
helptext['patterns'] = '''
Exclude patterns use a variant of shell pattern syntax, with '*' matching any
number of characters, '?' matching any single character, '[...]' matching any
single character specified, including ranges, and '[!...]' matching any
character not specified. For the purpose of these patterns, the path
separator ('\\' for Windows and '/' on other systems) is not treated
specially. For a path to match a pattern, it must completely match from
start to end, or must match from the start to just before a path separator.
Except for the root path, paths will never end in the path separator when
matching is attempted. Thus, if a given pattern ends in a path separator, a
'*' is appended before matching is attempted. Patterns with wildcards should
be quoted to protect them from shell expansion.
Examples:
# Exclude '/home/user/file.o' but not '/home/user/file.odt':
$ attic create -e '*.o' repo.attic /
# Exclude '/home/user/junk' and '/home/user/subdir/junk' but
# not '/home/user/importantjunk' or '/etc/junk':
$ attic create -e '/home/*/junk' repo.attic /
# Exclude the contents of '/home/user/cache' but not the directory itself:
$ attic create -e /home/user/cache/ repo.attic /
# The file '/home/user/cache/important' is *not* backed up:
$ attic create -e /home/user/cache/ repo.attic / /home/user/cache/important
'''
def do_help(self, args):
if args.topic in self.helptext:
print(self.helptext[args.topic])
else:
# FIXME: If topic is one of the regular commands, show that help.
# Otherwise, show the default global help.
print('No help available on %s' % (args.topic,))
return self.exit_code
def run(self, args=None): def run(self, args=None):
keys_dir = get_keys_dir() keys_dir = get_keys_dir()
if not os.path.exists(keys_dir): if not os.path.exists(keys_dir):
@ -365,7 +404,7 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
default=False, default=False,
help='verbose output') help='verbose output')
# We can't use argpase for "serve" since we don't want it to show up in "Available commands" # We can't use argparse for "serve" since we don't want it to show up in "Available commands"
if args and args[0] == 'serve': if args and args[0] == 'serve':
return self.do_serve() return self.do_serve()
@ -409,8 +448,11 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
subparser.add_argument('repository', metavar='REPOSITORY', subparser.add_argument('repository', metavar='REPOSITORY',
type=location_validator(archive=False)) type=location_validator(archive=False))
create_epilog = '''See "attic help patterns" for more help on exclude patterns.'''
subparser = subparsers.add_parser('create', parents=[common_parser], subparser = subparsers.add_parser('create', parents=[common_parser],
description=self.do_create.__doc__) description=self.do_create.__doc__,
epilog=create_epilog)
subparser.set_defaults(func=self.do_create) subparser.set_defaults(func=self.do_create)
subparser.add_argument('-s', '--stats', dest='stats', subparser.add_argument('-s', '--stats', dest='stats',
action='store_true', default=False, action='store_true', default=False,
@ -436,8 +478,11 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
subparser.add_argument('paths', metavar='PATH', nargs='+', type=str, subparser.add_argument('paths', metavar='PATH', nargs='+', type=str,
help='paths to archive') help='paths to archive')
extract_epilog = '''See "attic help patterns" for more help on exclude patterns.'''
subparser = subparsers.add_parser('extract', parents=[common_parser], subparser = subparsers.add_parser('extract', parents=[common_parser],
description=self.do_extract.__doc__) description=self.do_extract.__doc__,
epilog=extract_epilog)
subparser.set_defaults(func=self.do_extract) subparser.set_defaults(func=self.do_extract)
subparser.add_argument('-e', '--exclude', dest='excludes', subparser.add_argument('-e', '--exclude', dest='excludes',
type=ExcludePattern, action='append', type=ExcludePattern, action='append',
@ -480,8 +525,11 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
subparser.add_argument('-o', dest='options', type=str, subparser.add_argument('-o', dest='options', type=str,
help='Extra mount options') help='Extra mount options')
verify_epilog = '''See "attic help patterns" for more help on exclude patterns.'''
subparser = subparsers.add_parser('verify', parents=[common_parser], subparser = subparsers.add_parser('verify', parents=[common_parser],
description=self.do_verify.__doc__) description=self.do_verify.__doc__,
epilog=verify_epilog)
subparser.set_defaults(func=self.do_verify) subparser.set_defaults(func=self.do_verify)
subparser.add_argument('-e', '--exclude', dest='excludes', subparser.add_argument('-e', '--exclude', dest='excludes',
type=ExcludePattern, action='append', type=ExcludePattern, action='append',
@ -541,6 +589,13 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
subparser.add_argument('repository', metavar='REPOSITORY', subparser.add_argument('repository', metavar='REPOSITORY',
type=location_validator(archive=False), type=location_validator(archive=False),
help='repository to prune') help='repository to prune')
subparser = subparsers.add_parser('help', parents=[common_parser],
description='Extra help')
subparser.set_defaults(func=self.do_help)
subparser.add_argument('topic', metavar='TOPIC', type=str,
help='additional help on TOPIC')
args = parser.parse_args(args or ['-h']) args = parser.parse_args(args or ['-h'])
self.verbose = args.verbose self.verbose = args.verbose
update_excludes(args) update_excludes(args)