import argparse
parser = argparse.ArgumentParser(
prog="arena",
description="Book ice time at the community arena.",
epilog='Example: arena "Bantam A" 18 20')
parser.add_argument("team", help="name of the team or group")
parser.add_argument("start", type=int, help="start hour, 6 to 22 (24-hour clock)")
parser.add_argument("end", type=int, help="end hour, 7 to 23 (not included)")
parser.add_argument("--dry-run", action="store_true",
help="check the booking without saving it")
# A real program would call parser.parse_args() to read the command line.
# Here we pass a sample command line so the example runs anywhere.
args = parser.parse_args(["Bantam A", "18", "20", "--dry-run"])
print(args.team, args.start, args.end, args.dry_run)
print()
parser.print_help()
arena_cli.py: the help text is generated from the argument definitions.