Skip to content

Commit f214011

Browse files
authored
Merge pull request #82 from at-gmbh/feature/replay-hint
hint user to correct invalid inputs in replay-file #57
2 parents b92ae6c + dab4bf9 commit f214011

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

hooks/pre_gen_project.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,22 @@
3434
project_slug = '{{ cookiecutter.project_slug }}'
3535
module_name = '{{ cookiecutter.module_name }}'
3636

37+
invalid_inputs = list()
3738
if not re.match(SLUG_REGEX, project_slug):
3839
print("ERROR: {} is not a valid slug! It may only consist of numbers and letters of the "
3940
"english alphabet, begin with a letter, and must use dashes instead of whitespace."
4041
.format(project_slug))
41-
sys.exit(1)
42+
invalid_inputs.append("project_slug")
4243

4344
if not re.match(MODULE_REGEX, module_name):
4445
print("ERROR: {} is not a valid Python module name! "
4546
"See https://www.python.org/dev/peps/pep-0008/#package-and-module-names "
4647
"for naming standards.".format(module_name))
48+
invalid_inputs.append("module_name")
49+
50+
if invalid_inputs:
51+
print("\nYou have entered invalid configuration values for: "
52+
"{}".format(", ".join(invalid_inputs)))
53+
print("\nPlease fix your inputs in ~/.cookiecutter_replay/at-python-template.json")
54+
print("After that, rerun the template with: cookiecutter . --replay\n")
4755
sys.exit(1)

0 commit comments

Comments
 (0)