We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
output_dir for python API invocation + parametrize output_dir tests
Need this for a cookiecutter project that's tested using [python api](http://cookiecutter.readthedocs.org/en/latest/advanced_usage.html#calling-cookiecutter-functions-from-python).

Also parametrize output_dir tests and add testcase for cookiecutter python object.


--- 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 
15 import click
16 
17 from cookiecutter import __version__
18 from cookiecutter.main import cookiecutter
19 from cookiecutter.exceptions import (
20     OutputDirExistsException, InvalidModeException
21 )
22 
23 logger = logging.getLogger(__name__)
24 
25 
26 def version_msg():
27     python_version = sys.version[:3]
28     location = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
29     message = u'Cookiecutter %(version)s from {} (Python {})'
30     return message.format(location, python_version)
31 
32 
33 @click.command()
34 @click.version_option(__version__, u'-V', u'--version', message=version_msg())
35 @click.argument(u'template')
36 @click.option(
37     u'--no-input', is_flag=True,
38     help=u'Do not prompt for parameters and only use cookiecutter.json '
39          u'file content',
40 )
41 @click.option(
42     u'-c', u'--checkout',
43     help=u'branch, tag or commit to checkout after git clone',
44 )
45 @click.option(
46     '-v', '--verbose',
47     is_flag=True, help='Print debug information', default=False
48 )
49 @click.option(
50     u'--replay', is_flag=True,
51     help=u'Do not prompt for parameters and only use information entered '
52          u'previously',
53 )
54 @click.option(
55     u'-f', u'--overwrite-if-exists', is_flag=True,
56     help=u'Overwrite the contents of the output directory if it already exists'
57 )
58 def main(template, no_input, checkout, verbose, replay, overwrite_if_exists):
59     """Create a project from a Cookiecutter project template (TEMPLATE)."""
60     if verbose:
61         logging.basicConfig(
62             format=u'%(levelname)s %(filename)s: %(message)s',
63             level=logging.DEBUG
64         )
65     else:
66         # Log info and above to console
67         logging.basicConfig(
68             format=u'%(levelname)s: %(message)s',
69             level=logging.INFO
70         )
71 
72     try:
73         cookiecutter(template, checkout, no_input, replay=replay,
74                      overwrite_if_exists=overwrite_if_exists)
75     except (OutputDirExistsException, InvalidModeException) as e:
76         click.echo(e)
77         sys.exit(1)
78 
79 if __name__ == "__main__":
80     main()
81
```

Path: `cookiecutter/main.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 """
5 cookiecutter.main
6 -----------------
7 
8 Main entry point for the `cookiecutter` command.
9 
10 The code in this module is also a good example of how to use Cookiecutter as a
11 library rather than a script.
12 """
13 
14 from __future__ import unicode_literals
15 import logging
16 import os
17 import re
18 
19 from .config import get_user_config
20 from .exceptions import InvalidModeException
21 from .prompt import prompt_for_config
22 from .generate import generate_context, generate_files
23 from .vcs import clone
24 from .replay import dump, load
25 
26 logger = logging.getLogger(__name__)
27 
28 builtin_abbreviations = {
29     'gh': 'https://github.com/{0}.git',
30     'bb': 'https://bitbucket.org/{0}',
31 }
32 
33 REPO_REGEX = """
34 (
35 ((git|ssh|https|http):(//)?)    # something like git:// ssh:// etc.
36  |                              # or
37  (\w+@[\w\.]+)                  # something like user@...
38 )
39 .*
40 """
41 
42 
43 def is_repo_url(value):
44     """Return True if value is a repository URL."""
45     return bool(re.match(REPO_REGEX, value, re.VERBOSE))
46 
47 
48 def expand_abbreviations(template, config_dict):
49     """
50     Expand abbreviations in a template name.
51 
52     :param template: The project template name.
53     :param config_dict: The user config, which will contain abbreviation
54         definitions.
55     """
56 
57     abbreviations = builtin_abbreviations.copy()
58     abbreviations.update(config_dict.get('abbreviations', {}))
59 
60     if template in abbreviations:
61         return abbreviations[template]
62 
63     # Split on colon. If there is no colon, rest will be empty
64     # and prefix will be the whole template
65     prefix, sep, rest = template.partition(':')
66     if prefix in abbreviations:
67         return abbreviations[prefix].format(rest)
68 
69     return template
70 
71 
72 def cookiecutter(
73         template, checkout=None, no_input=False, extra_context=None,
74         replay=False, overwrite_if_exists=False):
75     """
76     API equivalent to using Cookiecutter at the command line.
77 
78     :param template: A directory containing a project template directory,
79         or a URL to a git repository.
80     :param checkout: The branch, tag or commit ID to checkout after clone.
81     :param no_input: Prompt the user at command line for manual configuration?
82     :param extra_context: A dictionary of context that overrides default
83         and user configuration.
84     :param: overwrite_if_exists: Overwrite the contents of output directory
85         if it exists
86     """
87     if replay and ((no_input is not False) or (extra_context is not None)):
88         err_msg = (
89             "You can not use both replay and no_input or extra_context "
90             "at the same time."
91         )
92         raise InvalidModeException(err_msg)
93 
94     # Get user config from ~/.cookiecutterrc or equivalent
95     # If no config file, sensible defaults from config.DEFAULT_CONFIG are used
96     config_dict = get_user_config()
97 
98     template = expand_abbreviations(template, config_dict)
99 
100     if is_repo_url(template):
101         repo_dir = clone(
102             repo_url=template,
103             checkout=checkout,
104             clone_to_dir=config_dict['cookiecutters_dir'],
105             no_input=no_input
106         )
107     else:
108         # If it's a local repo, no need to clone or copy to your
109         # cookiecutters_dir
110         repo_dir = template
111 
112     template_name = os.path.basename(template)
113 
114     if replay:
115         context = load(template_name)
116     else:
117         context_file = os.path.join(repo_dir, 'cookiecutter.json')
118         logging.debug('context_file is {0}'.format(context_file))
119 
120         context = generate_context(
121             context_file=context_file,
122             default_context=config_dict['default_context'],
123             extra_context=extra_context,
124         )
125 
126         # prompt the user to manually configure at the command line.
127         # except when 'no-input' flag is set
128         context['cookiecutter'] = prompt_for_config(context, no_input)
129 
130         dump(template_name, context)
131 
132     # Create project from local context and project template.
133     generate_files(
134         repo_dir=repo_dir,
135         context=context,
136         overwrite_if_exists=overwrite_if_exists
137     )
138
```
--- 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
@@ -55,7 +55,12 @@
     u'-f', u'--overwrite-if-exists', is_flag=True,
     help=u'Overwrite the contents of the output directory if it already exists'
 )
-def main(template, no_input, checkout, verbose, replay, overwrite_if_exists):
+@click.option(
+    u'-o', u'--output-dir', default='.', type=click.Path(),
+    help=u'Where to output the generated project dir into'
+)
+def main(template, no_input, checkout, verbose, replay, overwrite_if_exists,
+         output_dir):
     """Create a project from a Cookiecutter project template (TEMPLATE)."""
     if verbose:
         logging.basicConfig(
@@ -70,8 +75,12 @@
         )
 
     try:
-        cookiecutter(template, checkout, no_input, replay=replay,
-                     overwrite_if_exists=overwrite_if_exists)
+        cookiecutter(
+            template, checkout, no_input,
+            replay=replay,
+            overwrite_if_exists=overwrite_if_exists,
+            output_dir=output_dir
+        )
     except (OutputDirExistsException, InvalidModeException) as e:
         click.echo(e)
         sys.exit(1)
diff --git a/cookiecutter/main.py b/cookiecutter/main.py
--- a/cookiecutter/main.py
+++ b/cookiecutter/main.py
@@ -71,7 +71,7 @@
 
 def cookiecutter(
         template, checkout=None, no_input=False, extra_context=None,
-        replay=False, overwrite_if_exists=False):
+        replay=False, overwrite_if_exists=False, output_dir='.'):
     """
     API equivalent to using Cookiecutter at the command line.
 
@@ -83,6 +83,7 @@
         and user configuration.
     :param: overwrite_if_exists: Overwrite the contents of output directory
         if it exists
+    :param output_dir: Where to output the generated project dir into.
     """
     if replay and ((no_input is not False) or (extra_context is not None)):
         err_msg = (
@@ -133,5 +134,6 @@
     generate_files(
         repo_dir=repo_dir,
         context=context,
-        overwrite_if_exists=overwrite_if_exists
+        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@@ -55,7 +55,12 @@\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-def main(template, no_input, checkout, verbose, replay, overwrite_if_exists):\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+def main(template, no_input, checkout, verbose, replay, overwrite_if_exists,\n+         output_dir):\n     \"\"\"Create a project from a Cookiecutter project template (TEMPLATE).\"\"\"\n     if verbose:\n         logging.basicConfig(\n@@ -70,8 +75,12 @@\n         )\n \n     try:\n-        cookiecutter(template, checkout, no_input, replay=replay,\n-                     overwrite_if_exists=overwrite_if_exists)\n+        cookiecutter(\n+            template, checkout, no_input,\n+            replay=replay,\n+            overwrite_if_exists=overwrite_if_exists,\n+            output_dir=output_dir\n+        )\n     except (OutputDirExistsException, InvalidModeException) as e:\n         click.echo(e)\n         sys.exit(1)\ndiff --git a/cookiecutter/main.py b/cookiecutter/main.py\n--- a/cookiecutter/main.py\n+++ b/cookiecutter/main.py\n@@ -71,7 +71,7 @@\n \n def cookiecutter(\n         template, checkout=None, no_input=False, extra_context=None,\n-        replay=False, overwrite_if_exists=False):\n+        replay=False, overwrite_if_exists=False, output_dir='.'):\n     \"\"\"\n     API equivalent to using Cookiecutter at the command line.\n \n@@ -83,6 +83,7 @@\n         and user configuration.\n     :param: overwrite_if_exists: Overwrite the contents of output directory\n         if it exists\n+    :param output_dir: Where to output the generated project dir into.\n     \"\"\"\n     if replay and ((no_input is not False) or (extra_context is not None)):\n         err_msg = (\n@@ -133,5 +134,6 @@\n     generate_files(\n         repo_dir=repo_dir,\n         context=context,\n-        overwrite_if_exists=overwrite_if_exists\n+        overwrite_if_exists=overwrite_if_exists,\n+        output_dir=output_dir\n     )\n", "issue": "output_dir for python API invocation + parametrize output_dir tests\nNeed this for a cookiecutter project that's tested using [python api](http://cookiecutter.readthedocs.org/en/latest/advanced_usage.html#calling-cookiecutter-functions-from-python).\n\nAlso parametrize output_dir tests and add testcase for cookiecutter python object.\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\n\nimport click\n\nfrom cookiecutter import __version__\nfrom cookiecutter.main import cookiecutter\nfrom cookiecutter.exceptions import (\n    OutputDirExistsException, InvalidModeException\n)\n\nlogger = logging.getLogger(__name__)\n\n\ndef version_msg():\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()\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)\ndef main(template, no_input, checkout, verbose, replay, overwrite_if_exists):\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        cookiecutter(template, checkout, no_input, replay=replay,\n                     overwrite_if_exists=overwrite_if_exists)\n    except (OutputDirExistsException, InvalidModeException) as e:\n        click.echo(e)\n        sys.exit(1)\n\nif __name__ == \"__main__\":\n    main()\n", "path": "cookiecutter/cli.py"}, {"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\ncookiecutter.main\n-----------------\n\nMain entry point for the `cookiecutter` command.\n\nThe code in this module is also a good example of how to use Cookiecutter as a\nlibrary rather than a script.\n\"\"\"\n\nfrom __future__ import unicode_literals\nimport logging\nimport os\nimport re\n\nfrom .config import get_user_config\nfrom .exceptions import InvalidModeException\nfrom .prompt import prompt_for_config\nfrom .generate import generate_context, generate_files\nfrom .vcs import clone\nfrom .replay import dump, load\n\nlogger = logging.getLogger(__name__)\n\nbuiltin_abbreviations = {\n    'gh': 'https://github.com/{0}.git',\n    'bb': 'https://bitbucket.org/{0}',\n}\n\nREPO_REGEX = \"\"\"\n(\n((git|ssh|https|http):(//)?)    # something like git:// ssh:// etc.\n |                              # or\n (\\w+@[\\w\\.]+)                  # something like user@...\n)\n.*\n\"\"\"\n\n\ndef is_repo_url(value):\n    \"\"\"Return True if value is a repository URL.\"\"\"\n    return bool(re.match(REPO_REGEX, value, re.VERBOSE))\n\n\ndef expand_abbreviations(template, config_dict):\n    \"\"\"\n    Expand abbreviations in a template name.\n\n    :param template: The project template name.\n    :param config_dict: The user config, which will contain abbreviation\n        definitions.\n    \"\"\"\n\n    abbreviations = builtin_abbreviations.copy()\n    abbreviations.update(config_dict.get('abbreviations', {}))\n\n    if template in abbreviations:\n        return abbreviations[template]\n\n    # Split on colon. If there is no colon, rest will be empty\n    # and prefix will be the whole template\n    prefix, sep, rest = template.partition(':')\n    if prefix in abbreviations:\n        return abbreviations[prefix].format(rest)\n\n    return template\n\n\ndef cookiecutter(\n        template, checkout=None, no_input=False, extra_context=None,\n        replay=False, overwrite_if_exists=False):\n    \"\"\"\n    API equivalent to using Cookiecutter at the command line.\n\n    :param template: A directory containing a project template directory,\n        or a URL to a git repository.\n    :param checkout: The branch, tag or commit ID to checkout after clone.\n    :param no_input: Prompt the user at command line for manual configuration?\n    :param extra_context: A dictionary of context that overrides default\n        and user configuration.\n    :param: overwrite_if_exists: Overwrite the contents of output directory\n        if it exists\n    \"\"\"\n    if replay and ((no_input is not False) or (extra_context is not None)):\n        err_msg = (\n            \"You can not use both replay and no_input or extra_context \"\n            \"at the same time.\"\n        )\n        raise InvalidModeException(err_msg)\n\n    # Get user config from ~/.cookiecutterrc or equivalent\n    # If no config file, sensible defaults from config.DEFAULT_CONFIG are used\n    config_dict = get_user_config()\n\n    template = expand_abbreviations(template, config_dict)\n\n    if is_repo_url(template):\n        repo_dir = clone(\n            repo_url=template,\n            checkout=checkout,\n            clone_to_dir=config_dict['cookiecutters_dir'],\n            no_input=no_input\n        )\n    else:\n        # If it's a local repo, no need to clone or copy to your\n        # cookiecutters_dir\n        repo_dir = template\n\n    template_name = os.path.basename(template)\n\n    if replay:\n        context = load(template_name)\n    else:\n        context_file = os.path.join(repo_dir, 'cookiecutter.json')\n        logging.debug('context_file is {0}'.format(context_file))\n\n        context = generate_context(\n            context_file=context_file,\n            default_context=config_dict['default_context'],\n            extra_context=extra_context,\n        )\n\n        # prompt the user to manually configure at the command line.\n        # except when 'no-input' flag is set\n        context['cookiecutter'] = prompt_for_config(context, no_input)\n\n        dump(template_name, context)\n\n    # Create project from local context and project template.\n    generate_files(\n        repo_dir=repo_dir,\n        context=context,\n        overwrite_if_exists=overwrite_if_exists\n    )\n", "path": "cookiecutter/main.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\n\nimport click\n\nfrom cookiecutter import __version__\nfrom cookiecutter.main import cookiecutter\nfrom cookiecutter.exceptions import (\n    OutputDirExistsException, InvalidModeException\n)\n\nlogger = logging.getLogger(__name__)\n\n\ndef version_msg():\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()\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)\ndef main(template, no_input, checkout, verbose, replay, overwrite_if_exists,\n         output_dir):\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        cookiecutter(\n            template, checkout, no_input,\n            replay=replay,\n            overwrite_if_exists=overwrite_if_exists,\n            output_dir=output_dir\n        )\n    except (OutputDirExistsException, InvalidModeException) as e:\n        click.echo(e)\n        sys.exit(1)\n\nif __name__ == \"__main__\":\n    main()\n", "path": "cookiecutter/cli.py"}, {"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\ncookiecutter.main\n-----------------\n\nMain entry point for the `cookiecutter` command.\n\nThe code in this module is also a good example of how to use Cookiecutter as a\nlibrary rather than a script.\n\"\"\"\n\nfrom __future__ import unicode_literals\nimport logging\nimport os\nimport re\n\nfrom .config import get_user_config\nfrom .exceptions import InvalidModeException\nfrom .prompt import prompt_for_config\nfrom .generate import generate_context, generate_files\nfrom .vcs import clone\nfrom .replay import dump, load\n\nlogger = logging.getLogger(__name__)\n\nbuiltin_abbreviations = {\n    'gh': 'https://github.com/{0}.git',\n    'bb': 'https://bitbucket.org/{0}',\n}\n\nREPO_REGEX = \"\"\"\n(\n((git|ssh|https|http):(//)?)    # something like git:// ssh:// etc.\n |                              # or\n (\\w+@[\\w\\.]+)                  # something like user@...\n)\n.*\n\"\"\"\n\n\ndef is_repo_url(value):\n    \"\"\"Return True if value is a repository URL.\"\"\"\n    return bool(re.match(REPO_REGEX, value, re.VERBOSE))\n\n\ndef expand_abbreviations(template, config_dict):\n    \"\"\"\n    Expand abbreviations in a template name.\n\n    :param template: The project template name.\n    :param config_dict: The user config, which will contain abbreviation\n        definitions.\n    \"\"\"\n\n    abbreviations = builtin_abbreviations.copy()\n    abbreviations.update(config_dict.get('abbreviations', {}))\n\n    if template in abbreviations:\n        return abbreviations[template]\n\n    # Split on colon. If there is no colon, rest will be empty\n    # and prefix will be the whole template\n    prefix, sep, rest = template.partition(':')\n    if prefix in abbreviations:\n        return abbreviations[prefix].format(rest)\n\n    return template\n\n\ndef cookiecutter(\n        template, checkout=None, no_input=False, extra_context=None,\n        replay=False, overwrite_if_exists=False, output_dir='.'):\n    \"\"\"\n    API equivalent to using Cookiecutter at the command line.\n\n    :param template: A directory containing a project template directory,\n        or a URL to a git repository.\n    :param checkout: The branch, tag or commit ID to checkout after clone.\n    :param no_input: Prompt the user at command line for manual configuration?\n    :param extra_context: A dictionary of context that overrides default\n        and user configuration.\n    :param: overwrite_if_exists: Overwrite the contents of output directory\n        if it exists\n    :param output_dir: Where to output the generated project dir into.\n    \"\"\"\n    if replay and ((no_input is not False) or (extra_context is not None)):\n        err_msg = (\n            \"You can not use both replay and no_input or extra_context \"\n            \"at the same time.\"\n        )\n        raise InvalidModeException(err_msg)\n\n    # Get user config from ~/.cookiecutterrc or equivalent\n    # If no config file, sensible defaults from config.DEFAULT_CONFIG are used\n    config_dict = get_user_config()\n\n    template = expand_abbreviations(template, config_dict)\n\n    if is_repo_url(template):\n        repo_dir = clone(\n            repo_url=template,\n            checkout=checkout,\n            clone_to_dir=config_dict['cookiecutters_dir'],\n            no_input=no_input\n        )\n    else:\n        # If it's a local repo, no need to clone or copy to your\n        # cookiecutters_dir\n        repo_dir = template\n\n    template_name = os.path.basename(template)\n\n    if replay:\n        context = load(template_name)\n    else:\n        context_file = os.path.join(repo_dir, 'cookiecutter.json')\n        logging.debug('context_file is {0}'.format(context_file))\n\n        context = generate_context(\n            context_file=context_file,\n            default_context=config_dict['default_context'],\n            extra_context=extra_context,\n        )\n\n        # prompt the user to manually configure at the command line.\n        # except when 'no-input' flag is set\n        context['cookiecutter'] = prompt_for_config(context, no_input)\n\n        dump(template_name, context)\n\n    # Create project from local context and project template.\n    generate_files(\n        repo_dir=repo_dir,\n        context=context,\n        overwrite_if_exists=overwrite_if_exists,\n        output_dir=output_dir\n    )\n", "path": "cookiecutter/main.py"}]}