-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp-cmd.py
executable file
·35 lines (32 loc) · 998 Bytes
/
help-cmd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
"""": # -*-python-*-
bup_python="$(dirname "$0")/bup-python" || exit $?
exec "$bup_python" "$0" ${1+"$@"}
"""
# end of bup preamble
from __future__ import absolute_import
import sys, os, glob
from bup import options, path
optspec = """
bup help <command>
"""
o = options.Options(optspec)
(opt, flags, extra) = o.parse(sys.argv[1:])
if len(extra) == 0:
# the wrapper program provides the default usage string
os.execvp(os.environ['BUP_MAIN_EXE'], ['bup'])
elif len(extra) == 1:
docname = (extra[0]=='bup' and 'bup' or ('bup-%s' % extra[0]))
manpath = os.path.join(path.exedir(),
'Documentation/' + docname + '.[1-9]')
g = glob.glob(manpath)
try:
if g:
os.execvp('man', ['man', '-l', g[0]])
else:
os.execvp('man', ['man', docname])
except OSError as e:
sys.stderr.write('Unable to run man command: %s\n' % e)
sys.exit(1)
else:
o.fatal("exactly one command name expected")