Skip to content

Add show_envvar as global setting via context_settings (like show_default) #2313

@gertvdijk

Description

@gertvdijk

The context_settings / Context object allows for global setting of some option/command variables. For example, to show the default for all options and setting an auto-envvar-prefix, one can do this via context_settings:

@click.command(context_settings=dict(show_default=True, auto_envvar_prefix="MYAPP"))
@click.option("--host", default="127.0.0.1")
@click.option("--port", default="1234")

Now, to also show the environment variable for each option in the --help output, it's required to add show_envvar=True for each option:

@click.option("--host", default="127.0.0.1", show_envvar=True)
@click.option("--port", default="1234", show_envvar=True)

I'd like to have this available as global setting as well, ie., I wish this would work:

@click.command(context_settings=dict(show_default=True, auto_envvar_prefix="MYAPP", show_envvar=True))
@click.option("--host", default="127.0.0.1")
@click.option("--port", default="1234")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions