def add_arg(p,*args,**kwds):
    """Add an argument or option to a parser

    Given an arbitrary parser instance, adds a new
    option or argument using the appropriate method
    call and passing the supplied arguments and
    keywords.

    For example, if the parser is an instance of
    argparse.ArgumentParser, then the 'add_argument'
    method will be invoked to add a new argument to
    the parser.

    Arguments:
      p (Object): parser instance
      args (List): list of argument values to pass
        directly to the argument-addition method
      kwds (mapping): keyword-value mapping to pass
        directly to the argument-addition method

    """
    for add_arg in ('add_argument','add_option',):
        try:
            return getattr(p,add_arg)(*args,**kwds)
        except AttributeError:
            pass
    raise Exception("Unrecognised subparser class")