Builds the command parser.

    This needs to be exported in order for Sphinx to document it correctly.

    Returns:
      An instance of an ``argparse.ArgumentParser`` that parses all the
      commands supported by the PyLink CLI.

def create_parser():
    """Builds the command parser.

    This needs to be exported in order for Sphinx to document it correctly.

    Returns:
      An instance of an ``argparse.ArgumentParser`` that parses all the
      commands supported by the PyLink CLI.
    """
    parser = argparse.ArgumentParser(prog=pylink.__title__,
                                     description=pylink.__description__,
                                     epilog=pylink.__copyright__)
    parser.add_argument('--version', action='version',
                        version='%(prog)s ' + pylink.__version__)
    parser.add_argument('-v', '--verbose', action='count', default=0,
                        help='increase output verbosity')

    kwargs = {}
    kwargs['title'] = 'command'
    kwargs['description'] = 'specify subcommand to run'
    kwargs['help'] = 'subcommands'
    subparsers = parser.add_subparsers(**kwargs)

    for command in commands():
        kwargs = {}
        kwargs['name'] = command.name
        kwargs['description'] = command.description
        kwargs['help'] = command.help
        subparser = subparsers.add_parser(**kwargs)
        subparser.set_defaults(command=command.run)
        command.add_arguments(subparser)

    return parser