Skip to content
Myr

Make example work with setup tools entry points

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Add handling for `ctx.obj is None` in an example command, with a comment noting that the handling is there in case of invocations other than the `if __name__ == '__main__'` block. This especially covers setuptools entry points, but other usages as well. Use `ctx.ensure_object` for clarity / as a current best-practice. closes #572

authored by Kaushik Ghose · committed by Stephen Rosen · parent 7463db5 · Browse files · 1 file+4 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−0 removed

  • other:+4 added−0 removed

1 file+4 added−0 removed

modified:docs/commands.rst+4 added
85 unmodified lines
86 @click.group()87 @click.option('--debug/--no-debug', default=False)88 @click.pass_context89 def cli(ctx, debug):90 # ensure that ctx.obj exists and is a dict (in case `cli()` is called91 # by means other than the `if` block below92 ctx.ensure_object(dict)9394 ctx.obj['DEBUG'] = debug9596 @cli.command()97 @click.pass_context
465 unmodified lines