parameters: (option_parser, argv=None)
docstring: Parses options/args from argv and runs the specified command.
  
    Args:
      option_parser: A CommandOptionParser object.
      argv: Command line arguments. If None, automatically draw from sys.argv.
  
    Returns:
      An exit code.
docstring_summary: Parses options/args from argv and runs the specified command.
docstring_tokens: Parses options / args from argv and runs the specified command .
function: def ParseAndExecute(option_parser, argv=None):
    """Parses options/args from argv and runs the specified command.
  
    Args:
      option_parser: A CommandOptionParser object.
      argv: Command line arguments. If None, automatically draw from sys.argv.
  
    Returns:
      An exit code.
    """
    if not argv:
      argv = sys.argv
  
      if len(argv) < 2 or argv[1] not in option_parser.commands_dict:
        # Parse args first, if this is '--help', optparse will print help and exit
        option_parser.parse_args(argv)
        option_parser.error('Invalid command.')
  
      cmd = option_parser.commands_dict[argv[1]]
      cmd.add_options_func(option_parser)
      options, args = option_parser.parse_args(argv)
      return cmd.run_command_func(argv[1], options, args, option_parser)
function_tokens: def ParseAndExecute ( option_parser , argv = None ) : if not argv : argv = sys . argv if len ( argv ) < 2 or argv [ 1 ] not in option_parser . commands_dict : # Parse args first, if this is '--help', optparse will print help and exit option_parser . parse_args ( argv ) option_parser . error ( 'Invalid command.' ) cmd = option_parser . commands_dict [ argv [ 1 ] ] cmd . add_options_func ( option_parser ) options , args = option_parser . parse_args ( argv ) return cmd . run_command_func ( argv [ 1 ] , options , args , option_parser )