I have the following config:
mymodule/__init__.py:
@click.group()
@click.option('--env', required=True, type=str, help='Environment: t1, t2, t22,..., s, p', default=lambda: getenv("APP_ENV"))
@click.option('--load-type', help='Load type', type=str)
@click.option('--start-date', default=None, help='Start date', type=str)
@click.option('--end-date', default=None, help='End date', type=str)
@click.pass_context
def cli(ctx, env, load_type, start_date, end_date):
ctx.ensure_object(dict)
ctx['env'] = env
ctx['load_type'] = load_type
ctx['start_date'] = start_date
ctx['end_date'] = end_date
foo.py
from . import cli
@cli.command()
@click.pass_context
def foo(ctx):
with App(ctx['env'], ctx['load_type'], ctx['start_date'], ctx['end_date']) as app:
app.start()
And setup.py
'console_scripts': [
'app=mymodule:cli'
]
When I run app --help, I get this:
(myvenv) bash$ app --help
Usage: app [OPTIONS] COMMAND [ARGS]...
Options:
--env TEXT Environment: t1, t2, t22,..., s, p [required]
--load-type TEXT Load type
--start-date TEXT Start date
--end-date TEXT End date
--help Show this message and exit.
However, I don't get a section for available commands one of which is foo
That is, I need to see this:
(myvenv) bash$ app --help
Usage: app [OPTIONS] COMMAND [ARGS]...
Options:
--env TEXT Environment: t1, t2, t22,..., s, p [required]
--load-type TEXT Load type
--start-date TEXT Start date
--end-date TEXT End date
--help Show this message and exit.
Commands:
foo