def main(args=None):
    """Main function for usage of psyplot from the command line

    This function creates a parser that parses command lines to the
    :func:`make_plot` functions or (if the ``psyplot_gui`` module is
    present, to the :func:`psyplot_gui.start_app` function)

    Returns
    -------
    psyplot.parser.FuncArgParser
        The parser that has been used from the command line"""
    try:
        from psyplot_gui import get_parser as _get_parser
    except ImportError:
        logger.debug('Failed to import gui', exc_info=True)
        parser = get_parser(create=False)
        parser.update_arg('output', required=True)
        parser.create_arguments()
        parser.parse2func(args)
    else:
        parser = _get_parser(create=False)
        parser.create_arguments()
        parser.parse_known2func(args)