-
An example inspired by the Click docs: @click.command()
@click.option('--username')
def greet(username):
click.echo(f'Hello {username}!')
def cli():
greet(auto_envvar_prefix='GREETER') Note that I wrap In [project.scripts]
greet = 'greeter.cli:cli' When testing, I also have to ensure that I use runner = CliRunner()
result = runner.invoke(env_config, args, auto_envvar_prefix='GREETER') Its not a big thing but that permits drift between what's happening normally and testing. Am I missing an obvious way of being able to make |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Is there a way to get the |
Beta Was this translation helpful? Give feedback.
I came across this discussion while I was looking for a solution that does not require me to pass
auto_envvar_prefix
multiple times and instead rely on the top-level group/command provide the information for click to interpret later. Which was my understand of "as part of CLI declaration" as opposed to the "imperative" way of wrapping the top-level callable and passing the prefix.I found the
context_settings
argument to help with this