File: help-cmd.py

package info (click to toggle)
bup 0.17b-2squeeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,416 kB
  • ctags: 1,420
  • sloc: python: 18,377; ansic: 311; sh: 284; perl: 160; makefile: 129
file content (25 lines) | stat: -rwxr-xr-x 746 bytes parent folder | download
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
#!/usr/bin/env python
import sys, os, glob
from bup import options

optspec = """
bup help <command>
"""
o = options.Options('bup help', 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]))
    exe = sys.argv[0]
    (exepath, exefile) = os.path.split(exe)
    manpath = os.path.join(exepath, '../Documentation/' + docname + '.[1-9]')
    g = glob.glob(manpath)
    if g:
        os.execvp('man', ['man', '-l', g[0]])
    else:
        os.execvp('man', ['man', docname])
else:
    o.fatal("exactly one command name expected")