Skip to content
Myr

renamed context to environment to reduce confusion

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

authored by Ming Zhang · committed by Ming Zhang · parent 2d42cd4 · Browse files · 3 files+7 added−7 removed
This commit

State

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

Diff stats

3 files+7 added−7 removed

  • other:+7 added−7 removed

3 files+7 added−7 removed

modified:examples/complex/complex/commands/cmd_init.py+2 added-2 removed
1import click2from complex.cli import pass_context2from complex.cli import pass_environment345@click.command('init', short_help='Initializes a repo.')6@click.argument('path', required=False, type=click.Path(resolve_path=True))7@pass_context7@pass_environment8def cli(ctx, path):9 """Initializes a repository."""10 if path is None:11 path = ctx.home
2 unmodified lines
modified:examples/complex/complex/commands/cmd_status.py+2 added-2 removed
1import click2from complex.cli import pass_context2from complex.cli import pass_environment345@click.command('status', short_help='Shows file changes.')6@pass_context6@pass_environment7def cli(ctx):8 """Shows file changes in the current working directory."""9 ctx.log('Changed files: none')10 ctx.vlog('bla bla bla, debug info')
modified:examples/complex/complex/cli.py+3 added-3 removed
4 unmodified lines
56CONTEXT_SETTINGS = dict(auto_envvar_prefix='COMPLEX')789class Context(object):9class Environment(object):1011 def __init__(self):12 self.verbose = False13 self.home = os.getcwd()
9 unmodified lines
23 if self.verbose:24 self.log(msg, *args)252627pass_context = click.make_pass_decorator(Context, ensure=True)27pass_environment = click.make_pass_decorator(Environment, ensure=True)28cmd_folder = os.path.abspath(os.path.join(os.path.dirname(__file__),29 'commands'))3031
24 unmodified lines
56 resolve_path=True),57 help='Changes the folder to operate on.')58@click.option('-v', '--verbose', is_flag=True,59 help='Enables verbose mode.')60@pass_context60@pass_environment61def cli(ctx, verbose, home):62 """A complex command line interface."""63 ctx.verbose = verbose64 if home is not None:
1 unmodified line