--- /dev/null
+#!/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('bup', ['bup'])
+elif len(extra) == 1:
+ docname = '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")
from bup.helpers import *
def usage():
- log('Usage: bup <subcmd> <options...>\n\n')
- log('Available subcommands:\n')
+ log('Usage: bup <command> <options...>\n\n')
+ log('Available commands:\n')
for c in sorted(os.listdir(cmdpath) + os.listdir(exepath)):
if c.startswith('bup-') and c.find('.') < 0:
log('\t%s\n' % c[4:])
+ log("\nSee 'bup help <command>' for more information on " +
+ "a specific command.\n")
sys.exit(99)
if len(argv) < 2 or not argv[1] or argv[1][0] == '-':
usage()
subcmd = argv[1]
-if subcmd == 'help':
- usage()
def subpath(s):
sp = os.path.join(exepath, 'bup-%s' % s)
already_fixed = atoi(os.environ.get('BUP_FORCE_TTY'))
-if subcmd in ['ftp']:
+if subcmd in ['ftp', 'help']:
already_fixed = True
fix_stdout = not already_fixed and os.isatty(1)
fix_stderr = not already_fixed and os.isatty(2)