Skip to content

Instantly share code, notes, and snippets.

@edusantana
Last active September 8, 2019 22:02
Show Gist options
  • Save edusantana/dd484f492c3310745ae51a409bb2810a to your computer and use it in GitHub Desktop.
Save edusantana/dd484f492c3310745ae51a409bb2810a to your computer and use it in GitHub Desktop.
click auto_envvar_prefix with setuptools

Trying auto_envvar_prefix with setuptools

pip install --editable .

Trying values-from-environment-variables

$ export GREETER_USERNAME=john
$ greet greet
Hello None!
import click
CONTEXT_SETTINGS = dict(
help_option_names=['-h', '--help'],
auto_envvar_prefix='GREETER'
)
@click.group(context_settings=CONTEXT_SETTINGS)
def cli():
pass
@cli.command()
@click.option('--username')
def greet(username):
click.echo('Hello %s!' % username)
from setuptools import setup
setup(
name='greet',
version='0.1',
py_modules=['greet'],
install_requires=[
'Click',
],
entry_points='''
[console_scripts]
greet=greet:cli
''',
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment