def extended_help_option(extended_help=None, *param_decls, **attrs):
    """
    Based on the click.help_option code.

    Adds a ``--extended-help`` option which immediately ends the program
    printing out the extended extended-help page. Defaults to using the
    callback's doc string, but can be given an explicit value as well.

    This is intended for use as a decorator on a command to provide a 3rd level
    of help verbosity suitable for use as a manpage (though not formatted as such explicitly).

    Like :func:`version_option`, this is implemented as eager option that
    prints in the callback and exits.

    All arguments are forwarded to :func:`option`.
    """

    def decorator(f):
        def callback(ctx, param, value):
            if value and not ctx.resilient_parsing:
                if not extended_help:
                    ctx.command.help = ctx.command.callback.__doc__
                    click.echo(ctx.get_help(), color=ctx.color)
                else:
                    ctx.command.help = extended_help
                    click.echo(ctx.get_help(), color=ctx.color)
                ctx.exit()

        attrs.setdefault('is_flag', True)
        attrs.setdefault('expose_value', False)
        attrs.setdefault('help', 'Show extended help content, similar to manpage, and exit.')
        attrs.setdefault('is_eager', True)
        attrs['callback'] = callback
        return click.option(*(param_decls or ('--extended-help',)), **attrs)(f)

    return decorator
Based on the click.help_option code.

    Adds a ``--extended-help`` option which immediately ends the program
    printing out the extended extended-help page. Defaults to using the
    callback's doc string, but can be given an explicit value as well.

    This is intended for use as a decorator on a command to provide a 3rd level
    of help verbosity suitable for use as a manpage (though not formatted as such explicitly).

    Like :func:`version_option`, this is implemented as eager option that
    prints in the callback and exits.

    All arguments are forwarded to :func:`option`.