def common_api_auth_options(f):
    """Add common API authentication options to commands."""

    @click.option(
        "-k",
        "--api-key",
        hide_input=True,
        envvar="CLOUDSMITH_API_KEY",
        help="The API key for authenticating with the API.",
    )
    @click.pass_context
    @functools.wraps(f)
    def wrapper(ctx, *args, **kwargs):
        # pylint: disable=missing-docstring
        opts = config.get_or_create_options(ctx)
        opts.api_key = kwargs.pop("api_key")
        kwargs["opts"] = opts
        return ctx.invoke(f, *args, **kwargs)

    return wrapper
def common_api_auth_options ( f ) : @ click . option ( "-k" , "--api-key" , hide_input = True , envvar = "CLOUDSMITH_API_KEY" , help = "The API key for authenticating with the API." , ) @ click . pass_context @ functools . wraps ( f ) def wrapper ( ctx , * args , ** kwargs ) : opts = config . get_or_create_options ( ctx ) opts . api_key = kwargs . pop ( "api_key" ) kwargs [ "opts" ] = opts return ctx . invoke ( f , * args , ** kwargs ) return wrapper
Add common API authentication options to commands.