sys.argv (index 0 is the script name). Write parse_args(argv) that takes such a list and returns a dict: first real argument is 'command', and any --key=value pairs become entries. Non-flag extras go into a 'targets' list.parse_args(['tool.py', 'deploy', '--env=prod', 'web1', 'web2'])
{'command': 'deploy', 'env': 'prod', 'targets': ['web1', 'web2']}argv[0] is skipped; flags and targets are separated.
Slice argv[1:] before processing.
arg.startswith('--') and '=' in arg identifies flags.