1import argparse
2
3def get_main_parser():
4 parser = argparse.ArgumentParser(prog="hello")
5 parser.add_argument(
6 "who", help="good question", nargs="?", default="world")
7 parser.add_argument(
8 "--what", help="a better question", default="hello",
9 choices=["hello", "goodbye"])
10 return parser
11
12if __name__ == "__main__":
13 parser = get_main_parser()
14 args = parser.parse_args()
15 print("{}, {}!".format(args.what, args.who))