Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand cli documentation relating to the no-input flag (#1543) #1587

Merged
merged 3 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions cookiecutter/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def list_installed_templates(default_config, passed_config_file):
@click.option(
'--no-input',
is_flag=True,
help='Do not prompt for parameters and only use cookiecutter.json file content',
help='Do not prompt for parameters and only use cookiecutter.json file content. '
'Defaults to deleting any cached resources and redownloading them. '
'Cannot be combined with the --replay flag.',
)
@click.option(
'-c', '--checkout', help='branch, tag or commit to checkout after git clone',
Expand All @@ -91,7 +93,8 @@ def list_installed_templates(default_config, passed_config_file):
@click.option(
'--replay',
is_flag=True,
help='Do not prompt for parameters and only use information entered previously',
help='Do not prompt for parameters and only use information entered previously. '
'Cannot be combined with the --no-input flag or with extra configuration passed.',
)
@click.option(
'--replay-file',
Expand Down
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.
:param 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