We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Idea: have a way to specify context via command line
Something like repeat arguments:

```
cookiecutter mytemplate -Cname=my-project -Cgithub-user=ionelmc
```

Or maybe the whole json?

```
cookiecutter mytemplate --context='{"name": "my-project", "github-user": "ionelmc"}'
```

Or variable arguments?

```
cookiecutter mytemplate --context-name=my-project --context-github-user=ionelmc
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `cookiecutter/cli.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 """
5 cookiecutter.cli
6 -----------------
7 
8 Main `cookiecutter` CLI.
9 """
10 
11 import os
12 import sys
13 import logging
14 import json
15 
16 import click
17 
18 from cookiecutter import __version__
19 from cookiecutter.config import USER_CONFIG_PATH
20 from cookiecutter.main import cookiecutter
21 from cookiecutter.exceptions import (
22     OutputDirExistsException,
23     InvalidModeException,
24     FailedHookException,
25     UndefinedVariableInTemplate,
26     UnknownExtension,
27     RepositoryNotFound
28 )
29 
30 logger = logging.getLogger(__name__)
31 
32 
33 def version_msg():
34     """Returns the Cookiecutter version, location and Python powering it."""
35     python_version = sys.version[:3]
36     location = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
37     message = u'Cookiecutter %(version)s from {} (Python {})'
38     return message.format(location, python_version)
39 
40 
41 @click.command(context_settings=dict(help_option_names=[u'-h', u'--help']))
42 @click.version_option(__version__, u'-V', u'--version', message=version_msg())
43 @click.argument(u'template')
44 @click.option(
45     u'--no-input', is_flag=True,
46     help=u'Do not prompt for parameters and only use cookiecutter.json '
47          u'file content',
48 )
49 @click.option(
50     u'-c', u'--checkout',
51     help=u'branch, tag or commit to checkout after git clone',
52 )
53 @click.option(
54     '-v', '--verbose',
55     is_flag=True, help='Print debug information', default=False
56 )
57 @click.option(
58     u'--replay', is_flag=True,
59     help=u'Do not prompt for parameters and only use information entered '
60          u'previously',
61 )
62 @click.option(
63     u'-f', u'--overwrite-if-exists', is_flag=True,
64     help=u'Overwrite the contents of the output directory if it already exists'
65 )
66 @click.option(
67     u'-o', u'--output-dir', default='.', type=click.Path(),
68     help=u'Where to output the generated project dir into'
69 )
70 @click.option(
71     u'--config-file', type=click.Path(), default=USER_CONFIG_PATH,
72     help=u'User configuration file'
73 )
74 @click.option(
75     u'--default-config', is_flag=True,
76     help=u'Do not load a config file. Use the defaults instead'
77 )
78 def main(template, no_input, checkout, verbose, replay, overwrite_if_exists,
79          output_dir, config_file, default_config):
80     """Create a project from a Cookiecutter project template (TEMPLATE)."""
81     if verbose:
82         logging.basicConfig(
83             format=u'%(levelname)s %(filename)s: %(message)s',
84             level=logging.DEBUG
85         )
86     else:
87         # Log info and above to console
88         logging.basicConfig(
89             format=u'%(levelname)s: %(message)s',
90             level=logging.INFO
91         )
92 
93     try:
94         # If you _need_ to support a local template in a directory
95         # called 'help', use a qualified path to the directory.
96         if template == u'help':
97             click.echo(click.get_current_context().get_help())
98             sys.exit(0)
99 
100         user_config = None if default_config else config_file
101 
102         cookiecutter(
103             template, checkout, no_input,
104             replay=replay,
105             overwrite_if_exists=overwrite_if_exists,
106             output_dir=output_dir,
107             config_file=user_config
108         )
109     except (OutputDirExistsException,
110             InvalidModeException,
111             FailedHookException,
112             UnknownExtension,
113             RepositoryNotFound) as e:
114         click.echo(e)
115         sys.exit(1)
116     except UndefinedVariableInTemplate as undefined_err:
117         click.echo('{}'.format(undefined_err.message))
118         click.echo('Error message: {}'.format(undefined_err.error.message))
119 
120         context_str = json.dumps(
121             undefined_err.context,
122             indent=4,
123             sort_keys=True
124         )
125         click.echo('Context: {}'.format(context_str))
126         sys.exit(1)
127 
128 
129 if __name__ == "__main__":
130     main()
131
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/cookiecutter/cli.py b/cookiecutter/cli.py
--- a/cookiecutter/cli.py
+++ b/cookiecutter/cli.py
@@ -38,9 +38,23 @@
     return message.format(location, python_version)
 
 
+def validate_extra_context(ctx, param, value):
+    for s in value:
+        if '=' not in s:
+            raise click.BadParameter(
+                'EXTRA_CONTEXT should contain items of the form key=value; '
+                "'{}' doesn't match that form".format(s)
+            )
+
+    # Convert tuple -- e.g.: (u'program_name=foobar', u'startsecs=66')
+    # to dict -- e.g.: {'program_name': 'foobar', 'startsecs': '66'}
+    return dict(s.split('=', 1) for s in value) or None
+
+
 @click.command(context_settings=dict(help_option_names=[u'-h', u'--help']))
 @click.version_option(__version__, u'-V', u'--version', message=version_msg())
 @click.argument(u'template')
+@click.argument(u'extra_context', nargs=-1, callback=validate_extra_context)
 @click.option(
     u'--no-input', is_flag=True,
     help=u'Do not prompt for parameters and only use cookiecutter.json '
@@ -75,8 +89,8 @@
     u'--default-config', is_flag=True,
     help=u'Do not load a config file. Use the defaults instead'
 )
-def main(template, no_input, checkout, verbose, replay, overwrite_if_exists,
-         output_dir, config_file, default_config):
+def main(template, extra_context, no_input, checkout, verbose, replay,
+         overwrite_if_exists, output_dir, config_file, default_config):
     """Create a project from a Cookiecutter project template (TEMPLATE)."""
     if verbose:
         logging.basicConfig(
@@ -101,6 +115,7 @@
 
         cookiecutter(
             template, checkout, no_input,
+            extra_context=extra_context,
             replay=replay,
             overwrite_if_exists=overwrite_if_exists,
             output_dir=output_dir,

{"golden_diff": "diff --git a/cookiecutter/cli.py b/cookiecutter/cli.py\n--- a/cookiecutter/cli.py\n+++ b/cookiecutter/cli.py\n@@ -38,9 +38,23 @@\n     return message.format(location, python_version)\n \n \n+def validate_extra_context(ctx, param, value):\n+    for s in value:\n+        if '=' not in s:\n+            raise click.BadParameter(\n+                'EXTRA_CONTEXT should contain items of the form key=value; '\n+                \"'{}' doesn't match that form\".format(s)\n+            )\n+\n+    # Convert tuple -- e.g.: (u'program_name=foobar', u'startsecs=66')\n+    # to dict -- e.g.: {'program_name': 'foobar', 'startsecs': '66'}\n+    return dict(s.split('=', 1) for s in value) or None\n+\n+\n @click.command(context_settings=dict(help_option_names=[u'-h', u'--help']))\n @click.version_option(__version__, u'-V', u'--version', message=version_msg())\n @click.argument(u'template')\n+@click.argument(u'extra_context', nargs=-1, callback=validate_extra_context)\n @click.option(\n     u'--no-input', is_flag=True,\n     help=u'Do not prompt for parameters and only use cookiecutter.json '\n@@ -75,8 +89,8 @@\n     u'--default-config', is_flag=True,\n     help=u'Do not load a config file. Use the defaults instead'\n )\n-def main(template, no_input, checkout, verbose, replay, overwrite_if_exists,\n-         output_dir, config_file, default_config):\n+def main(template, extra_context, no_input, checkout, verbose, replay,\n+         overwrite_if_exists, output_dir, config_file, default_config):\n     \"\"\"Create a project from a Cookiecutter project template (TEMPLATE).\"\"\"\n     if verbose:\n         logging.basicConfig(\n@@ -101,6 +115,7 @@\n \n         cookiecutter(\n             template, checkout, no_input,\n+            extra_context=extra_context,\n             replay=replay,\n             overwrite_if_exists=overwrite_if_exists,\n             output_dir=output_dir,\n", "issue": "Idea: have a way to specify context via command line\nSomething like repeat arguments:\n\n```\ncookiecutter mytemplate -Cname=my-project -Cgithub-user=ionelmc\n```\n\nOr maybe the whole json?\n\n```\ncookiecutter mytemplate --context='{\"name\": \"my-project\", \"github-user\": \"ionelmc\"}'\n```\n\nOr variable arguments?\n\n```\ncookiecutter mytemplate --context-name=my-project --context-github-user=ionelmc\n```\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\ncookiecutter.cli\n-----------------\n\nMain `cookiecutter` CLI.\n\"\"\"\n\nimport os\nimport sys\nimport logging\nimport json\n\nimport click\n\nfrom cookiecutter import __version__\nfrom cookiecutter.config import USER_CONFIG_PATH\nfrom cookiecutter.main import cookiecutter\nfrom cookiecutter.exceptions import (\n    OutputDirExistsException,\n    InvalidModeException,\n    FailedHookException,\n    UndefinedVariableInTemplate,\n    UnknownExtension,\n    RepositoryNotFound\n)\n\nlogger = logging.getLogger(__name__)\n\n\ndef version_msg():\n    \"\"\"Returns the Cookiecutter version, location and Python powering it.\"\"\"\n    python_version = sys.version[:3]\n    location = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n    message = u'Cookiecutter %(version)s from {} (Python {})'\n    return message.format(location, python_version)\n\n\n@click.command(context_settings=dict(help_option_names=[u'-h', u'--help']))\n@click.version_option(__version__, u'-V', u'--version', message=version_msg())\n@click.argument(u'template')\n@click.option(\n    u'--no-input', is_flag=True,\n    help=u'Do not prompt for parameters and only use cookiecutter.json '\n         u'file content',\n)\n@click.option(\n    u'-c', u'--checkout',\n    help=u'branch, tag or commit to checkout after git clone',\n)\n@click.option(\n    '-v', '--verbose',\n    is_flag=True, help='Print debug information', default=False\n)\n@click.option(\n    u'--replay', is_flag=True,\n    help=u'Do not prompt for parameters and only use information entered '\n         u'previously',\n)\n@click.option(\n    u'-f', u'--overwrite-if-exists', is_flag=True,\n    help=u'Overwrite the contents of the output directory if it already exists'\n)\n@click.option(\n    u'-o', u'--output-dir', default='.', type=click.Path(),\n    help=u'Where to output the generated project dir into'\n)\n@click.option(\n    u'--config-file', type=click.Path(), default=USER_CONFIG_PATH,\n    help=u'User configuration file'\n)\n@click.option(\n    u'--default-config', is_flag=True,\n    help=u'Do not load a config file. Use the defaults instead'\n)\ndef main(template, no_input, checkout, verbose, replay, overwrite_if_exists,\n         output_dir, config_file, default_config):\n    \"\"\"Create a project from a Cookiecutter project template (TEMPLATE).\"\"\"\n    if verbose:\n        logging.basicConfig(\n            format=u'%(levelname)s %(filename)s: %(message)s',\n            level=logging.DEBUG\n        )\n    else:\n        # Log info and above to console\n        logging.basicConfig(\n            format=u'%(levelname)s: %(message)s',\n            level=logging.INFO\n        )\n\n    try:\n        # If you _need_ to support a local template in a directory\n        # called 'help', use a qualified path to the directory.\n        if template == u'help':\n            click.echo(click.get_current_context().get_help())\n            sys.exit(0)\n\n        user_config = None if default_config else config_file\n\n        cookiecutter(\n            template, checkout, no_input,\n            replay=replay,\n            overwrite_if_exists=overwrite_if_exists,\n            output_dir=output_dir,\n            config_file=user_config\n        )\n    except (OutputDirExistsException,\n            InvalidModeException,\n            FailedHookException,\n            UnknownExtension,\n            RepositoryNotFound) as e:\n        click.echo(e)\n        sys.exit(1)\n    except UndefinedVariableInTemplate as undefined_err:\n        click.echo('{}'.format(undefined_err.message))\n        click.echo('Error message: {}'.format(undefined_err.error.message))\n\n        context_str = json.dumps(\n            undefined_err.context,\n            indent=4,\n            sort_keys=True\n        )\n        click.echo('Context: {}'.format(context_str))\n        sys.exit(1)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "cookiecutter/cli.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\ncookiecutter.cli\n-----------------\n\nMain `cookiecutter` CLI.\n\"\"\"\n\nimport os\nimport sys\nimport logging\nimport json\n\nimport click\n\nfrom cookiecutter import __version__\nfrom cookiecutter.config import USER_CONFIG_PATH\nfrom cookiecutter.main import cookiecutter\nfrom cookiecutter.exceptions import (\n    OutputDirExistsException,\n    InvalidModeException,\n    FailedHookException,\n    UndefinedVariableInTemplate,\n    UnknownExtension,\n    RepositoryNotFound\n)\n\nlogger = logging.getLogger(__name__)\n\n\ndef version_msg():\n    \"\"\"Returns the Cookiecutter version, location and Python powering it.\"\"\"\n    python_version = sys.version[:3]\n    location = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n    message = u'Cookiecutter %(version)s from {} (Python {})'\n    return message.format(location, python_version)\n\n\ndef validate_extra_context(ctx, param, value):\n    for s in value:\n        if '=' not in s:\n            raise click.BadParameter(\n                'EXTRA_CONTEXT should contain items of the form key=value; '\n                \"'{}' doesn't match that form\".format(s)\n            )\n\n    # Convert tuple -- e.g.: (u'program_name=foobar', u'startsecs=66')\n    # to dict -- e.g.: {'program_name': 'foobar', 'startsecs': '66'}\n    return dict(s.split('=', 1) for s in value) or None\n\n\n@click.command(context_settings=dict(help_option_names=[u'-h', u'--help']))\n@click.version_option(__version__, u'-V', u'--version', message=version_msg())\n@click.argument(u'template')\n@click.argument(u'extra_context', nargs=-1, callback=validate_extra_context)\n@click.option(\n    u'--no-input', is_flag=True,\n    help=u'Do not prompt for parameters and only use cookiecutter.json '\n         u'file content',\n)\n@click.option(\n    u'-c', u'--checkout',\n    help=u'branch, tag or commit to checkout after git clone',\n)\n@click.option(\n    '-v', '--verbose',\n    is_flag=True, help='Print debug information', default=False\n)\n@click.option(\n    u'--replay', is_flag=True,\n    help=u'Do not prompt for parameters and only use information entered '\n         u'previously',\n)\n@click.option(\n    u'-f', u'--overwrite-if-exists', is_flag=True,\n    help=u'Overwrite the contents of the output directory if it already exists'\n)\n@click.option(\n    u'-o', u'--output-dir', default='.', type=click.Path(),\n    help=u'Where to output the generated project dir into'\n)\n@click.option(\n    u'--config-file', type=click.Path(), default=USER_CONFIG_PATH,\n    help=u'User configuration file'\n)\n@click.option(\n    u'--default-config', is_flag=True,\n    help=u'Do not load a config file. Use the defaults instead'\n)\ndef main(template, extra_context, no_input, checkout, verbose, replay,\n         overwrite_if_exists, output_dir, config_file, default_config):\n    \"\"\"Create a project from a Cookiecutter project template (TEMPLATE).\"\"\"\n    if verbose:\n        logging.basicConfig(\n            format=u'%(levelname)s %(filename)s: %(message)s',\n            level=logging.DEBUG\n        )\n    else:\n        # Log info and above to console\n        logging.basicConfig(\n            format=u'%(levelname)s: %(message)s',\n            level=logging.INFO\n        )\n\n    try:\n        # If you _need_ to support a local template in a directory\n        # called 'help', use a qualified path to the directory.\n        if template == u'help':\n            click.echo(click.get_current_context().get_help())\n            sys.exit(0)\n\n        user_config = None if default_config else config_file\n\n        cookiecutter(\n            template, checkout, no_input,\n            extra_context=extra_context,\n            replay=replay,\n            overwrite_if_exists=overwrite_if_exists,\n            output_dir=output_dir,\n            config_file=user_config\n        )\n    except (OutputDirExistsException,\n            InvalidModeException,\n            FailedHookException,\n            UnknownExtension,\n            RepositoryNotFound) as e:\n        click.echo(e)\n        sys.exit(1)\n    except UndefinedVariableInTemplate as undefined_err:\n        click.echo('{}'.format(undefined_err.message))\n        click.echo('Error message: {}'.format(undefined_err.error.message))\n\n        context_str = json.dumps(\n            undefined_err.context,\n            indent=4,\n            sort_keys=True\n        )\n        click.echo('Context: {}'.format(context_str))\n        sys.exit(1)\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "cookiecutter/cli.py"}]}