def append_subparser(subparser, cmd, func, formatter_class=None):
    """Attach a command to a subparser, generating help from docstrings.

    Args:
        subparser: An argparse-based subparser to attach a command to.
        cmd: The command name.
        func: The function to call for said command.
        formatter: Whether to apply custom formatting for sub-subparser commands.

    """
    assert func.__doc__, "empty docstring: {}".format(func)
    help_ = func.__doc__.split("\n")[0].lower().strip(".")
    desc = func.__doc__.strip()

    if formatter_class:
        parser = subparser.add_parser(
            cmd,
            help=help_,
            description=desc,
            formatter_class=formatter_class
        )
    else:
        parser = subparser.add_parser(cmd, help=help_, description=desc)

    parser.set_defaults(func=func)

    return parser