1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-25 17:27:31 +00:00

Generate man page for borgfs (fixes #3216)

This commit is contained in:
Milkey Mouse 2017-11-05 14:46:25 -08:00
parent 18b934496c
commit eadb74eb6f
No known key found for this signature in database
GPG key ID: C6EF5A02F5647987
2 changed files with 19 additions and 6 deletions

1
docs/usage/borgfs.rst Normal file
View file

@ -0,0 +1 @@
.. include:: borgfs.rst.inc

View file

@ -238,10 +238,11 @@ def run(self):
# allows us to build docs without the C modules fully loaded during help generation
from borg.archiver import Archiver
parser = Archiver(prog='borg').build_parser()
borgfs_parser = Archiver(prog='borgfs').build_parser()
self.generate_level("", parser, Archiver)
self.generate_level("", parser, Archiver, {'borgfs': borgfs_parser})
def generate_level(self, prefix, parser, Archiver):
def generate_level(self, prefix, parser, Archiver, extra_choices=None):
is_subcommand = False
choices = {}
for action in parser._actions:
@ -249,6 +250,8 @@ def generate_level(self, prefix, parser, Archiver):
is_subcommand = True
for cmd, parser in action.choices.items():
choices[prefix + cmd] = parser
if extra_choices is not None:
choices.update(extra_choices)
if prefix and not choices:
return
print('found commands: %s' % list(choices.keys()))
@ -501,12 +504,13 @@ def run(self):
# allows us to build docs without the C modules fully loaded during help generation
from borg.archiver import Archiver
parser = Archiver(prog='borg').build_parser()
borgfs_parser = Archiver(prog='borgfs').build_parser()
self.generate_level('', parser, Archiver)
self.generate_level('', parser, Archiver, {'borgfs': borgfs_parser})
self.build_topic_pages(Archiver)
self.build_intro_page()
def generate_level(self, prefix, parser, Archiver):
def generate_level(self, prefix, parser, Archiver, extra_choices=None):
is_subcommand = False
choices = {}
for action in parser._actions:
@ -514,6 +518,8 @@ def generate_level(self, prefix, parser, Archiver):
is_subcommand = True
for cmd, parser in action.choices.items():
choices[prefix + cmd] = parser
if extra_choices is not None:
choices.update(extra_choices)
if prefix and not choices:
return
@ -521,7 +527,10 @@ def generate_level(self, prefix, parser, Archiver):
if command.startswith('debug') or command == 'help':
continue
man_title = 'borg-' + command.replace(' ', '-')
if command == "borgfs":
man_title = command
else:
man_title = 'borg-' + command.replace(' ', '-')
print('building man page', man_title + '(1)', file=sys.stderr)
is_intermediary = self.generate_level(command + ' ', parser, Archiver)
@ -536,7 +545,10 @@ def generate_level(self, prefix, parser, Archiver):
write('| borg', '[common options]', command, subcommand, '...')
self.see_also.setdefault(command, []).append('%s-%s' % (command, subcommand))
else:
write('borg', '[common options]', command, end='')
if command == "borgfs":
write(command, end='')
else:
write('borg', '[common options]', command, end='')
self.write_usage(write, parser)
write('\n')