frontend: upper-case positional arguments in help messages

This commit is contained in:
Sebastien Bourdeauducq 2016-04-22 16:33:44 +08:00
parent 3492ff1105
commit 3cfef4264b
7 changed files with 28 additions and 22 deletions

View File

@ -60,9 +60,9 @@ def get_argparser():
help="increase logging level of the experiment") help="increase logging level of the experiment")
parser_add.add_argument("-q", "--quiet", default=0, action="count", parser_add.add_argument("-q", "--quiet", default=0, action="count",
help="decrease logging level of the experiment") help="decrease logging level of the experiment")
parser_add.add_argument("file", parser_add.add_argument("file", metavar="FILE",
help="file containing the experiment to run") help="file containing the experiment to run")
parser_add.add_argument("arguments", nargs="*", parser_add.add_argument("arguments", metavar="ARGUMENTS", nargs="*",
help="run arguments") help="run arguments")
parser_delete = subparsers.add_parser("delete", parser_delete = subparsers.add_parser("delete",
@ -70,13 +70,14 @@ def get_argparser():
"from the schedule") "from the schedule")
parser_delete.add_argument("-g", action="store_true", parser_delete.add_argument("-g", action="store_true",
help="request graceful termination") help="request graceful termination")
parser_delete.add_argument("rid", type=int, parser_delete.add_argument("rid", metavar="RID", type=int,
help="run identifier (RID)") help="run identifier (RID)")
parser_set_dataset = subparsers.add_parser( parser_set_dataset = subparsers.add_parser(
"set-dataset", help="add or modify a dataset") "set-dataset", help="add or modify a dataset")
parser_set_dataset.add_argument("name", help="name of the dataset") parser_set_dataset.add_argument("name", metavar="NAME",
parser_set_dataset.add_argument("value", help="name of the dataset")
parser_set_dataset.add_argument("value", metavar="VALUE",
help="value in PYON format") help="value in PYON format")
parser_set_dataset.add_argument("-p", "--persist", action="store_true", parser_set_dataset.add_argument("-p", "--persist", action="store_true",
help="make the dataset persistent") help="make the dataset persistent")
@ -88,7 +89,7 @@ def get_argparser():
parser_show = subparsers.add_parser( parser_show = subparsers.add_parser(
"show", help="show schedule, log, devices or datasets") "show", help="show schedule, log, devices or datasets")
parser_show.add_argument( parser_show.add_argument(
"what", "what", metavar="WHAT",
help="select object to show: schedule/log/devices/datasets") help="select object to show: schedule/log/devices/datasets")
subparsers.add_parser( subparsers.add_parser(
@ -98,7 +99,8 @@ def get_argparser():
"scan-repository", help="trigger a repository (re)scan") "scan-repository", help="trigger a repository (re)scan")
parser_scan_repos.add_argument("--async", action="store_true", parser_scan_repos.add_argument("--async", action="store_true",
help="trigger scan and return immediately") help="trigger scan and return immediately")
parser_scan_repos.add_argument("revision", default=None, nargs="?", parser_scan_repos.add_argument("revision", metavar="REVISION",
default=None, nargs="?",
help="use a specific repository revision " help="use a specific repository revision "
"(defaults to head)") "(defaults to head)")

View File

@ -25,9 +25,10 @@ def get_argparser():
parser.add_argument("-o", "--output", default=None, parser.add_argument("-o", "--output", default=None,
help="output file") help="output file")
parser.add_argument("file", parser.add_argument("file", metavar="FILE",
help="file containing the experiment to compile") help="file containing the experiment to compile")
parser.add_argument("arguments", nargs="*", help="run arguments") parser.add_argument("arguments", metavar="ARGUMENTS",
nargs="*", help="run arguments")
return parser return parser

View File

@ -21,7 +21,7 @@ def get_argparser():
p_read = subparsers.add_parser("read", p_read = subparsers.add_parser("read",
help="read key from core device config") help="read key from core device config")
p_read.add_argument("key", type=str, p_read.add_argument("key", metavar="KEY", type=str,
help="key to be read from core device config") help="key to be read from core device config")
p_write = subparsers.add_parser("write", p_write = subparsers.add_parser("write",
@ -39,7 +39,7 @@ def get_argparser():
p_delete = subparsers.add_parser("delete", p_delete = subparsers.add_parser("delete",
help="delete key from core device config") help="delete key from core device config")
p_delete.add_argument("key", nargs=argparse.REMAINDER, p_delete.add_argument("key", metavar="KEY", nargs=argparse.REMAINDER,
default=[], type=str, default=[], type=str,
help="key to be deleted from core device config") help="key to be deleted from core device config")

View File

@ -40,7 +40,7 @@ Prerequisites:
help="target adapter, default: %(default)s") help="target adapter, default: %(default)s")
parser.add_argument("-f", "--storage", help="write file to storage area") parser.add_argument("-f", "--storage", help="write file to storage area")
parser.add_argument("-d", "--dir", help="look for files in this directory") parser.add_argument("-d", "--dir", help="look for files in this directory")
parser.add_argument("ACTION", nargs="*", parser.add_argument("action", metavar="ACTION", nargs="*",
default="proxy gateware bios runtime start".split(), default="proxy gateware bios runtime start".split(),
help="actions to perform, default: %(default)s") help="actions to perform, default: %(default)s")
return parser return parser
@ -80,7 +80,7 @@ def main():
prog = [] prog = []
prog.append("init") prog.append("init")
for action in opts.ACTION: for action in opts.action:
if action == "proxy": if action == "proxy":
proxy_base = "bscan_spi_{}.bit".format(config["chip"]) proxy_base = "bscan_spi_{}.bit".format(config["chip"])
proxy = None proxy = None

View File

@ -14,9 +14,9 @@ from artiq.protocols.pc_rpc import AutoTarget, Client
def get_argparser(): def get_argparser():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="ARTIQ RPC tool") description="ARTIQ RPC tool")
parser.add_argument("server", parser.add_argument("server", metavar="SERVER",
help="hostname or IP of the controller to connect to") help="hostname or IP of the controller to connect to")
parser.add_argument("port", type=int, parser.add_argument("port", metavar="PORT", type=int,
help="TCP port to use to connect to the controller") help="TCP port to use to connect to the controller")
subparsers = parser.add_subparsers(dest="action") subparsers = parser.add_subparsers(dest="action")
subparsers.add_parser("list-targets", help="list existing targets") subparsers.add_parser("list-targets", help="list existing targets")
@ -25,8 +25,8 @@ def get_argparser():
parser_list_methods.add_argument("-t", "--target", help="target name") parser_list_methods.add_argument("-t", "--target", help="target name")
parser_call = subparsers.add_parser("call", help="call a target's method") parser_call = subparsers.add_parser("call", help="call a target's method")
parser_call.add_argument("-t", "--target", help="target name") parser_call.add_argument("-t", "--target", help="target name")
parser_call.add_argument("method", help="method name") parser_call.add_argument("method", metavar="METHOD", help="method name")
parser_call.add_argument("args", nargs=argparse.REMAINDER, parser_call.add_argument("args", metavar="ARGS", nargs=argparse.REMAINDER,
help="arguments") help="arguments")
parser_interactive = subparsers.add_parser("interactive", parser_interactive = subparsers.add_parser("interactive",
help="enter interactive mode " help="enter interactive mode "

View File

@ -128,9 +128,9 @@ def get_argparser(with_file=True):
help="write results to specified HDF5 file" help="write results to specified HDF5 file"
" (default: print them)") " (default: print them)")
if with_file: if with_file:
parser.add_argument("file", parser.add_argument("file", metavar="FILE",
help="file containing the experiment to run") help="file containing the experiment to run")
parser.add_argument("arguments", nargs="*", parser.add_argument("arguments", metavar="ARGUMENTS", nargs="*",
help="run arguments") help="run arguments")
return parser return parser

View File

@ -69,11 +69,14 @@ def bit2bin(bit, bin, flip=False):
if __name__ == "__main__": if __name__ == "__main__":
import argparse import argparse
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="Convert FPGA bit files to raw bin format suitable for flashing") description="Convert FPGA bit files to raw bin format "
"suitable for flashing")
parser.add_argument("-f", "--flip", dest="flip", action="store_true", parser.add_argument("-f", "--flip", dest="flip", action="store_true",
default=False, help="Flip 32-bit endianess (needed for Zynq)") default=False, help="Flip 32-bit endianess (needed for Zynq)")
parser.add_argument("bitfile", help="Input bit file name") parser.add_argument("bitfile", metavar="BITFILE",
parser.add_argument("binfile", help="Output bin file name") help="Input bit file name")
parser.add_argument("binfile", metavar="BINFILE",
help="Output bin file name")
args = parser.parse_args() args = parser.parse_args()
bit2bin(args.bitfile, args.binfile, args.flip) bit2bin(args.bitfile, args.binfile, args.flip)