argparse identify subparser code example
Example: python get subparser name
import argparse
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='command')
parser_python = subparsers.add_parser('python', help='some sub-command')
# ...
parser_java = subparsers.add_parser('java', help='some other sub-command')
# ...
args = parser.parse_args(command_line)
if args.command == 'python':
# do something
elif args.command == 'java':
# do something else