Skip to content

Commit

Permalink
Improve docstrings of the no_input flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuseppe Lumia committed Oct 26, 2021
1 parent a46eede commit e45e525
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion cookiecutter/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def cookiecutter(
:param template: A directory containing a project template directory,
or a URL to a git repository.
:param checkout: The branch, tag or commit ID to checkout after clone.
:param no_input: Prompt the user at command line for manual configuration?
:param no_input: Do not prompt for user input.
Use default values for template parameters taken from `cookiecutter.json`, user
config and `extra_dict`. Force a refresh of cached resources.
:param extra_context: A dictionary of context that overrides default
and user configuration.
:param replay: Do not prompt for input, instead read from saved json. If
Expand Down
5 changes: 2 additions & 3 deletions cookiecutter/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,9 @@ def render_variable(env, raw, cookiecutter_dict):
def prompt_choice_for_config(cookiecutter_dict, env, key, options, no_input):
"""Prompt user with a set of options to choose from.
Each of the possible choices is rendered beforehand.
:no_input: Do not prompt for user input and return the first available option.
"""
rendered_options = [render_variable(env, raw, cookiecutter_dict) for raw in options]

if no_input:
return rendered_options[0]
return read_user_choice(key, rendered_options)
Expand All @@ -181,7 +180,7 @@ def prompt_for_config(context, no_input=False):
"""Prompt user to enter a new config.
:param dict context: Source for field names and sample values.
:param no_input: Prompt the user at command line for manual configuration?
:param no_input: Do not prompt for user input and use only values from context.
"""
cookiecutter_dict = OrderedDict([])
env = StrictEnvironment(context=context)
Expand Down
3 changes: 2 additions & 1 deletion cookiecutter/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def determine_repo_dir(
definitions.
:param clone_to_dir: The directory to clone the repository into.
:param checkout: The branch, tag or commit ID to checkout after clone.
:param no_input: Prompt the user at command line for manual configuration?
:param no_input: Do not prompt for user input and eventually force a refresh of
cached resources.
:param password: The password to use when extracting the repository.
:param directory: Directory within repo where cookiecutter.json lives.
:return: A tuple containing the cookiecutter template directory, and
Expand Down
3 changes: 2 additions & 1 deletion cookiecutter/vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def clone(repo_url, checkout=None, clone_to_dir='.', no_input=False):
:param checkout: The branch, tag or commit ID to checkout after clone.
:param clone_to_dir: The directory to clone to.
Defaults to the current directory.
:param no_input: Suppress all user prompts when calling via API.
:param no_input: Do not prompt for user input and eventually force a refresh of
cached resources.
:returns: str with path to the new directory of the repository.
"""
# Ensure that clone_to_dir exists
Expand Down
3 changes: 2 additions & 1 deletion cookiecutter/zipfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def unzip(zip_uri, is_url, clone_to_dir='.', no_input=False, password=None):
:param is_url: Is the zip URI a URL or a file?
:param clone_to_dir: The cookiecutter repository directory
to put the archive into.
:param no_input: Suppress any prompts
:param no_input: Do not prompt for user input and eventually force a refresh of
cached resources.
:param password: The password to use when unpacking the repository.
"""
# Ensure that clone_to_dir exists
Expand Down
2 changes: 2 additions & 0 deletions docs/advanced/suppressing_prompts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Suppressing Command-Line Prompts

To suppress the prompts asking for input, use `no_input`.

Note: this option will force a refresh of cached resources.

Basic Example: Using the Defaults
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit e45e525

Please sign in to comment.