1import argparse
2
3parser = argparse.ArgumentParser()
4subparsers = parser.add_subparsers(dest='command')
5parser_python = subparsers.add_parser('python', help='some sub-command')
6# ...
7parser_java = subparsers.add_parser('java', help='some other sub-command')
8# ...
9args = parser.parse_args(command_line)
10
11if args.command == 'python':
12 # do something
13elif args.command == 'java':
14 # do something else