Made the CLI usage messages more verbose so that the CLI is self documenting.

This commit is contained in:
Kovid Goyal 2006-12-12 05:09:23 +00:00
parent c693c6f900
commit 3bade20d57

View File

@ -178,7 +178,7 @@ def main():
term = TerminalController() term = TerminalController()
cols = term.COLS cols = term.COLS
parser = OptionParser(usage="usage: %prog [options] command args\n\ncommand is one of: info, books, df, ls, cp, mkdir, touch, cat or rm\n\n"+ parser = OptionParser(usage="usage: %prog [options] command args\n\ncommand is one of: info, books, df, ls, cp, mkdir, touch, cat, rm\n\n"+
"For help on a particular command: %prog command", version="libprs500 version: " + VERSION) "For help on a particular command: %prog command", version="libprs500 version: " + VERSION)
parser.add_option("--log-packets", help="print out packet stream to stdout. "+\ parser.add_option("--log-packets", help="print out packet stream to stdout. "+\
"The numbers in the left column are byte offsets that allow the packet size to be read off easily.", "The numbers in the left column are byte offsets that allow the packet size to be read off easily.",
@ -208,13 +208,13 @@ def main():
print "\nBooks on storage card:" print "\nBooks on storage card:"
for book in dev.books(oncard=True): print book for book in dev.books(oncard=True): print book
elif command == "mkdir": elif command == "mkdir":
parser = OptionParser(usage="usage: %prog mkdir [options] path\n\npath must begin with /,a:/ or b:/") parser = OptionParser(usage="usage: %prog mkdir [options] path\nCreate a directory on the device\n\npath must begin with /,a:/ or b:/")
if len(args) != 1: if len(args) != 1:
parser.print_help() parser.print_help()
sys.exit(1) sys.exit(1)
dev.mkdir(args[0]) dev.mkdir(args[0])
elif command == "ls": elif command == "ls":
parser = OptionParser(usage="usage: %prog ls [options] path\n\npath must begin with /,a:/ or b:/") parser = OptionParser(usage="usage: %prog ls [options] path\nList files on the device\n\npath must begin with /,a:/ or b:/")
parser.add_option("--color", help="show ls output in color", dest="color", action="store_true", default=False) parser.add_option("--color", help="show ls output in color", dest="color", action="store_true", default=False)
parser.add_option("-l", help="In addition to the name of each file, print the file type, permissions, and timestamp (the modification time unless other times are selected). Times are local.", dest="ll", action="store_true", default=False) parser.add_option("-l", help="In addition to the name of each file, print the file type, permissions, and timestamp (the modification time unless other times are selected). Times are local.", dest="ll", action="store_true", default=False)
parser.add_option("-R", help="Recursively list subdirectories encountered. /dev and /proc are omitted", dest="recurse", action="store_true", default=False) parser.add_option("-R", help="Recursively list subdirectories encountered. /dev and /proc are omitted", dest="recurse", action="store_true", default=False)
@ -228,7 +228,7 @@ def main():
elif command == "info": elif command == "info":
info(dev) info(dev)
elif command == "cp": elif command == "cp":
usage="usage: %prog cp [options] source destination\n\n"+\ usage="usage: %prog cp [options] source destination\nCopy files to/from the device\n\n"+\
"One of source or destination must be a path on the device. \n\nDevice paths have the form\n"+\ "One of source or destination must be a path on the device. \n\nDevice paths have the form\n"+\
"prs500:mountpoint/my/path\n"+\ "prs500:mountpoint/my/path\n"+\
"where mountpoint is one of /, a: or b:\n\n"+\ "where mountpoint is one of /, a: or b:\n\n"+\
@ -267,7 +267,7 @@ def main():
return 1 return 1
elif command == "cat": elif command == "cat":
outfile = sys.stdout outfile = sys.stdout
parser = OptionParser(usage="usage: %prog cat path\n\npath should point to a file on the device and must begin with /,a:/ or b:/") parser = OptionParser(usage="usage: %prog cat path\nShow file on the device\n\npath should point to a file on the device and must begin with /,a:/ or b:/")
options, args = parser.parse_args(args) options, args = parser.parse_args(args)
if len(args) != 1: if len(args) != 1:
parser.print_help() parser.print_help()
@ -277,7 +277,7 @@ def main():
outfile = sys.stdout outfile = sys.stdout
dev.get_file(path, outfile) dev.get_file(path, outfile)
elif command == "rm": elif command == "rm":
parser = OptionParser(usage="usage: %prog rm path\n\npath should point to a file or empty directory on the device "+\ parser = OptionParser(usage="usage: %prog rm path\nDelete files from the device\n\npath should point to a file or empty directory on the device "+\
"and must begin with /,a:/ or b:/\n\n"+\ "and must begin with /,a:/ or b:/\n\n"+\
"rm will DELETE the file. Be very CAREFUL") "rm will DELETE the file. Be very CAREFUL")
options, args = parser.parse_args(args) options, args = parser.parse_args(args)
@ -286,7 +286,7 @@ def main():
return 1 return 1
dev.rm(args[0]) dev.rm(args[0])
elif command == "touch": elif command == "touch":
parser = OptionParser(usage="usage: %prog touch path\n\npath should point to a file on the device and must begin with /,a:/ or b:/\n\n"+ parser = OptionParser(usage="usage: %prog touch path\nCreate an empty file on the device\n\npath should point to a file on the device and must begin with /,a:/ or b:/\n\n"+
"Unfortunately, I cant figure out how to update file times on the device, so if path already exists, touch does nothing" ) "Unfortunately, I cant figure out how to update file times on the device, so if path already exists, touch does nothing" )
options, args = parser.parse_args(args) options, args = parser.parse_args(args)
if len(args) != 1: if len(args) != 1: