import click


def cli_option_quiet(func):
    """
    Decorator for adding a reusable CLI option `--quiet`/'-q'.
    """

    # noinspection PyUnusedLocal
    def _callback(ctx: click.Context, param: click.Option, value: bool):
        ctx_obj = ctx.ensure_object(dict)
        ctx_obj["quiet"] = value
        return value

    return click.option(
        '--quiet', '-q',
        is_flag=True,
        help="Disable output of log messages to the console entirely."
             " Note, this will also suppress error and warning messages.",
        callback=_callback
    )(func)