prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  complex example - misleading name for context
  The name `Context` and `pass_context` are misleading in the complex example, since the `Context` defined in the example shares a name with the click `Context`. Maybe a different name such as "Environment" or "Options" would be more appropriate.
  
  </issue>
  <code>
  [start of examples/complex/complex/commands/cmd_status.py]
  1 import click
  2 from complex.cli import pass_context
  3 
  4 
  5 @click.command('status', short_help='Shows file changes.')
  6 @pass_context
  7 def 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')
  11
  [end of examples/complex/complex/commands/cmd_status.py]
  [start of examples/complex/complex/cli.py]
  1 import os
  2 import sys
  3 import click
  4 
  5 
  6 CONTEXT_SETTINGS = dict(auto_envvar_prefix='COMPLEX')
  7 
  8 
  9 class Context(object):
  10 
  11     def __init__(self):
  12         self.verbose = False
  13         self.home = os.getcwd()
  14 
  15     def log(self, msg, *args):
  16         """Logs a message to stderr."""
  17         if args:
  18             msg %= args
  19         click.echo(msg, file=sys.stderr)
  20 
  21     def vlog(self, msg, *args):
  22         """Logs a message to stderr only if verbose is enabled."""
  23         if self.verbose:
  24             self.log(msg, *args)
  25 
  26 
  27 pass_context = click.make_pass_decorator(Context, ensure=True)
  28 cmd_folder = os.path.abspath(os.path.join(os.path.dirname(__file__),
  29                                           'commands'))
  30 
  31 
  32 class ComplexCLI(click.MultiCommand):
  33 
  34     def list_commands(self, ctx):
  35         rv = []
  36         for filename in os.listdir(cmd_folder):
  37             if filename.endswith('.py') and \
  38                filename.startswith('cmd_'):
  39                 rv.append(filename[4:-3])
  40         rv.sort()
  41         return rv
  42 
  43     def get_command(self, ctx, name):
  44         try:
  45             if sys.version_info[0] == 2:
  46                 name = name.encode('ascii', 'replace')
  47             mod = __import__('complex.commands.cmd_' + name,
  48                              None, None, ['cli'])
  49         except ImportError:
  50             return
  51         return mod.cli
  52 
  53 
  54 @click.command(cls=ComplexCLI, context_settings=CONTEXT_SETTINGS)
  55 @click.option('--home', type=click.Path(exists=True, file_okay=False,
  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_context
  61 def cli(ctx, verbose, home):
  62     """A complex command line interface."""
  63     ctx.verbose = verbose
  64     if home is not None:
  65         ctx.home = home
  66
  [end of examples/complex/complex/cli.py]
  [start of examples/complex/complex/commands/cmd_init.py]
  1 import click
  2 from complex.cli import pass_context
  3 
  4 
  5 @click.command('init', short_help='Initializes a repo.')
  6 @click.argument('path', required=False, type=click.Path(resolve_path=True))
  7 @pass_context
  8 def cli(ctx, path):
  9     """Initializes a repository."""
  10     if path is None:
  11         path = ctx.home
  12     ctx.log('Initialized the repository in %s',
  13             click.format_filename(path))
  14
  [end of examples/complex/complex/commands/cmd_init.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/examples/complex/complex/cli.py b/examples/complex/complex/cli.py
  --- a/examples/complex/complex/cli.py
  +++ b/examples/complex/complex/cli.py
  @@ -6,7 +6,7 @@
   CONTEXT_SETTINGS = dict(auto_envvar_prefix='COMPLEX')
   
   
  -class Context(object):
  +class Environment(object):
   
       def __init__(self):
           self.verbose = False
  @@ -24,7 +24,7 @@
               self.log(msg, *args)
   
   
  -pass_context = click.make_pass_decorator(Context, ensure=True)
  +pass_environment = click.make_pass_decorator(Environment, ensure=True)
   cmd_folder = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                             'commands'))
   
  @@ -57,7 +57,7 @@
                 help='Changes the folder to operate on.')
   @click.option('-v', '--verbose', is_flag=True,
                 help='Enables verbose mode.')
  -@pass_context
  +@pass_environment
   def cli(ctx, verbose, home):
       """A complex command line interface."""
       ctx.verbose = verbose
  diff --git a/examples/complex/complex/commands/cmd_init.py b/examples/complex/complex/commands/cmd_init.py
  --- a/examples/complex/complex/commands/cmd_init.py
  +++ b/examples/complex/complex/commands/cmd_init.py
  @@ -1,10 +1,10 @@
   import click
  -from complex.cli import pass_context
  +from complex.cli import pass_environment
   
   
   @click.command('init', short_help='Initializes a repo.')
   @click.argument('path', required=False, type=click.Path(resolve_path=True))
  -@pass_context
  +@pass_environment
   def cli(ctx, path):
       """Initializes a repository."""
       if path is None:
  diff --git a/examples/complex/complex/commands/cmd_status.py b/examples/complex/complex/commands/cmd_status.py
  --- a/examples/complex/complex/commands/cmd_status.py
  +++ b/examples/complex/complex/commands/cmd_status.py
  @@ -1,9 +1,9 @@
   import click
  -from complex.cli import pass_context
  +from complex.cli import pass_environment
   
   
   @click.command('status', short_help='Shows file changes.')
  -@pass_context
  +@pass_environment
   def cli(ctx):
       """Shows file changes in the current working directory."""
       ctx.log('Changed files: none')
  
verification_info: {"golden_diff": "diff --git a/examples/complex/complex/cli.py b/examples/complex/complex/cli.py\n--- a/examples/complex/complex/cli.py\n+++ b/examples/complex/complex/cli.py\n@@ -6,7 +6,7 @@\n CONTEXT_SETTINGS = dict(auto_envvar_prefix='COMPLEX')\n \n \n-class Context(object):\n+class Environment(object):\n \n     def __init__(self):\n         self.verbose = False\n@@ -24,7 +24,7 @@\n             self.log(msg, *args)\n \n \n-pass_context = click.make_pass_decorator(Context, ensure=True)\n+pass_environment = click.make_pass_decorator(Environment, ensure=True)\n cmd_folder = os.path.abspath(os.path.join(os.path.dirname(__file__),\n                                           'commands'))\n \n@@ -57,7 +57,7 @@\n               help='Changes the folder to operate on.')\n @click.option('-v', '--verbose', is_flag=True,\n               help='Enables verbose mode.')\n-@pass_context\n+@pass_environment\n def cli(ctx, verbose, home):\n     \"\"\"A complex command line interface.\"\"\"\n     ctx.verbose = verbose\ndiff --git a/examples/complex/complex/commands/cmd_init.py b/examples/complex/complex/commands/cmd_init.py\n--- a/examples/complex/complex/commands/cmd_init.py\n+++ b/examples/complex/complex/commands/cmd_init.py\n@@ -1,10 +1,10 @@\n import click\n-from complex.cli import pass_context\n+from complex.cli import pass_environment\n \n \n @click.command('init', short_help='Initializes a repo.')\n @click.argument('path', required=False, type=click.Path(resolve_path=True))\n-@pass_context\n+@pass_environment\n def cli(ctx, path):\n     \"\"\"Initializes a repository.\"\"\"\n     if path is None:\ndiff --git a/examples/complex/complex/commands/cmd_status.py b/examples/complex/complex/commands/cmd_status.py\n--- a/examples/complex/complex/commands/cmd_status.py\n+++ b/examples/complex/complex/commands/cmd_status.py\n@@ -1,9 +1,9 @@\n import click\n-from complex.cli import pass_context\n+from complex.cli import pass_environment\n \n \n @click.command('status', short_help='Shows file changes.')\n-@pass_context\n+@pass_environment\n def cli(ctx):\n     \"\"\"Shows file changes in the current working directory.\"\"\"\n     ctx.log('Changed files: none')\n", "issue": "complex example - misleading name for context\nThe name `Context` and `pass_context` are misleading in the complex example, since the `Context` defined in the example shares a name with the click `Context`. Maybe a different name such as \"Environment\" or \"Options\" would be more appropriate.\n", "before_files": [{"content": "import click\nfrom complex.cli import pass_context\n\n\n@click.command('status', short_help='Shows file changes.')\n@pass_context\ndef cli(ctx):\n    \"\"\"Shows file changes in the current working directory.\"\"\"\n    ctx.log('Changed files: none')\n    ctx.vlog('bla bla bla, debug info')\n", "path": "examples/complex/complex/commands/cmd_status.py"}, {"content": "import os\nimport sys\nimport click\n\n\nCONTEXT_SETTINGS = dict(auto_envvar_prefix='COMPLEX')\n\n\nclass Context(object):\n\n    def __init__(self):\n        self.verbose = False\n        self.home = os.getcwd()\n\n    def log(self, msg, *args):\n        \"\"\"Logs a message to stderr.\"\"\"\n        if args:\n            msg %= args\n        click.echo(msg, file=sys.stderr)\n\n    def vlog(self, msg, *args):\n        \"\"\"Logs a message to stderr only if verbose is enabled.\"\"\"\n        if self.verbose:\n            self.log(msg, *args)\n\n\npass_context = click.make_pass_decorator(Context, ensure=True)\ncmd_folder = os.path.abspath(os.path.join(os.path.dirname(__file__),\n                                          'commands'))\n\n\nclass ComplexCLI(click.MultiCommand):\n\n    def list_commands(self, ctx):\n        rv = []\n        for filename in os.listdir(cmd_folder):\n            if filename.endswith('.py') and \\\n               filename.startswith('cmd_'):\n                rv.append(filename[4:-3])\n        rv.sort()\n        return rv\n\n    def get_command(self, ctx, name):\n        try:\n            if sys.version_info[0] == 2:\n                name = name.encode('ascii', 'replace')\n            mod = __import__('complex.commands.cmd_' + name,\n                             None, None, ['cli'])\n        except ImportError:\n            return\n        return mod.cli\n\n\n@click.command(cls=ComplexCLI, context_settings=CONTEXT_SETTINGS)\n@click.option('--home', type=click.Path(exists=True, file_okay=False,\n                                        resolve_path=True),\n              help='Changes the folder to operate on.')\n@click.option('-v', '--verbose', is_flag=True,\n              help='Enables verbose mode.')\n@pass_context\ndef cli(ctx, verbose, home):\n    \"\"\"A complex command line interface.\"\"\"\n    ctx.verbose = verbose\n    if home is not None:\n        ctx.home = home\n", "path": "examples/complex/complex/cli.py"}, {"content": "import click\nfrom complex.cli import pass_context\n\n\n@click.command('init', short_help='Initializes a repo.')\n@click.argument('path', required=False, type=click.Path(resolve_path=True))\n@pass_context\ndef cli(ctx, path):\n    \"\"\"Initializes a repository.\"\"\"\n    if path is None:\n        path = ctx.home\n    ctx.log('Initialized the repository in %s',\n            click.format_filename(path))\n", "path": "examples/complex/complex/commands/cmd_init.py"}]}