Skip to content

Commit

Permalink
page --help usage info for tklbam-restore and tklbam-backup
Browse files Browse the repository at this point in the history
rational: with the backends the --help is getting too long to fit in one screen
  • Loading branch information
lirazsiri committed Oct 23, 2013
1 parent 49067c7 commit ea370b2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
18 changes: 10 additions & 8 deletions cmd_backup.py
Expand Up @@ -128,18 +128,20 @@
PATH_LOGFILE = "/var/log/tklbam-backup"

def usage(e=None):
from paged import stdout

if e:
print >> sys.stderr, "error: " + str(e)
print >> stdout, "error: " + str(e)

print >> sys.stderr, "Syntax: %s [ -options ] [ override ... ]" % sys.argv[0]
print >> stdout, "Syntax: %s [ -options ] [ override ... ]" % sys.argv[0]
tpl = Template(__doc__.strip())
conf = Conf()
print >> sys.stderr, tpl.substitute(CONF_PATH=conf.paths.conf,
CONF_OVERRIDES=conf.paths.overrides,
CONF_VOLSIZE=conf.volsize,
CONF_FULL_BACKUP=conf.full_backup,
CONF_S3_PARALLEL_UPLOADS=conf.s3_parallel_uploads,
LOGFILE=PATH_LOGFILE)
print >> stdout, tpl.substitute(CONF_PATH=conf.paths.conf,
CONF_OVERRIDES=conf.paths.overrides,
CONF_VOLSIZE=conf.volsize,
CONF_FULL_BACKUP=conf.full_backup,
CONF_S3_PARALLEL_UPLOADS=conf.s3_parallel_uploads,
LOGFILE=PATH_LOGFILE)
sys.exit(1)

def warn(e):
Expand Down
21 changes: 12 additions & 9 deletions cmd_restore.py
Expand Up @@ -237,16 +237,18 @@ def fatal(e):
sys.exit(1)

def usage(e=None):
from paged import stdout

if e:
print >> sys.stderr, "error: " + str(e)
print >> stdout, "error: " + str(e)

print >> sys.stderr, "Syntax: %s [ -options ] [ <hub-backup> ]" % sys.argv[0]
print >> stdout, "Syntax: %s [ -options ] [ <hub-backup> ]" % sys.argv[0]

tpl = Template(__doc__.strip())
conf = Conf()
print >> sys.stderr, tpl.substitute(CONF_PATH=conf.paths.conf,
CONF_RESTORE_CACHE_SIZE=conf.restore_cache_size,
CONF_RESTORE_CACHE_DIR=conf.restore_cache_dir)
print >> stdout, tpl.substitute(CONF_PATH=conf.paths.conf,
CONF_RESTORE_CACHE_SIZE=conf.restore_cache_size,
CONF_RESTORE_CACHE_DIR=conf.restore_cache_dir)

sys.exit(1)

Expand Down Expand Up @@ -274,6 +276,7 @@ def main():
try:
opts, args = getopt.gnu_getopt(sys.argv[1:], 'h',
['raw-download=',
'help',
'simulate',
'limits=', 'address=', 'keyfile=', 'force-profile=',
'logfile=',
Expand All @@ -291,7 +294,10 @@ def main():
conf = Conf()

for opt, val in opts:
if opt == '--raw-download':
if opt in ('-h', '--help'):
usage()

elif opt == '--raw-download':
raw_download_path = val
if exists(raw_download_path):
if not isdir(raw_download_path):
Expand Down Expand Up @@ -341,9 +347,6 @@ def main():
elif opt == '--noninteractive':
interactive = False

elif opt == '-h':
usage()

elif opt == '--restore-cache-size':
conf.restore_cache_size = val

Expand Down

0 comments on commit ea370b2

Please sign in to comment.