]> arthur.barton.de Git - bup.git/blob - lib/bup/cmd/help.py
Remove Client __del__ in favor of context management
[bup.git] / lib / bup / cmd / help.py
1
2 from __future__ import absolute_import
3 import os, glob, sys
4
5 from bup import options, path
6 from bup.compat import argv_bytes
7
8
9 optspec = """
10 bup help <command>
11 """
12
13 def main(argv):
14     o = options.Options(optspec)
15     opt, flags, extra = o.parse_bytes(argv[1:])
16
17     if len(extra) == 0:
18         # the wrapper program provides the default usage string
19         os.execvp(path.exe(), [path.exe()])
20     elif len(extra) == 1:
21         docname = (extra[0]=='bup' and b'bup' or (b'bup-%s' % argv_bytes(extra[0])))
22         manpath = os.path.join(path.exedir(),
23                                b'../../Documentation/' + docname + b'.[1-9]')
24         g = glob.glob(manpath)
25         try:
26             if g:
27                 os.execvp('man', ['man', '-l', g[0]])
28             else:
29                 os.execvp('man', ['man', docname])
30         except OSError as e:
31             sys.stderr.write('Unable to run man command: %s\n' % e)
32             sys.exit(1)
33     else:
34         o.fatal("exactly one command name expected")