code: def parse_arguments(argv):
      
      parser = argparse.ArgumentParser(description='seqmagick - Manipulate ' + \
         ' sequence files.', prog='seqmagick')
  
      parser.add_argument('-V', '--version', action='version',
              version='seqmagick v' + version,
              help="Print the version number and exit")
      parser.add_argument('-v', '--verbose', dest='verbosity',
              action='count', default=1,
              help="Be more verbose. Specify -vv or -vvv for even more")
      parser.add_argument('-q', '--quiet', action='store_const', const=0,
              dest='verbosity', help="Suppress output")
  
      # Subparsers
      subparsers = parser.add_subparsers(dest='subparser_name')
  
      parser_help = subparsers.add_parser('help',
              help='Detailed help for actions using help <action>')
  
      parser_help.add_argument('action')
  
      # Add actions
      actions = {}
      for name, mod in subcommands.itermodules():
          subparser = subparsers.add_parser(name, help=mod.__doc__,
                  description=mod.__doc__)
          mod.build_parser(subparser)
          actions[name] = mod.action
  
      arguments = parser.parse_args(argv)
      arguments.argv = argv
      action = arguments.subparser_name
  
      if action == 'help':
          return parse_arguments([str(arguments.action), '-h'])
  
      return actions[action], arguments
docs: Extract command-line arguments for different actions.