def set_up_arg_parser():
    parser = argparse.ArgumentParser(
        description='ZeroVM Package Manager',
        epilog=("See 'zpm <command> --help' for more information on a specific"
                " command."),
    )
    parser.add_argument('--version', action='version',
                        help='show the version number and exit',
                        version='zpm version %s' % zpmlib.__version__)

    subparsers = parser.add_subparsers(description='available subcommands',
                                       metavar='COMMAND')

    for cmd in all_commands():
        doclines = cmd.__doc__.splitlines()
        summary = doclines[0]
        description = '\n'.join(doclines[1:])
        subparser = subparsers.add_parser(cmd.__name__,
                                          help=summary,
                                          description=description)
        # Add arguments in reverse order: the last decorator
        # (bottom-most in the source) is called first, so its
        # arguments will be at the front of the list.
        for args, kwargs in reversed(getattr(cmd, '_args', [])):
            subparser.add_argument(*args, **kwargs)
        subparser.set_defaults(func=cmd)

    return parser
dataset/ETHPy150Open zerovm/zerovm-cli/zpmlib/commands.py/set_up_arg_parser/original