Skip to content

Commit

Permalink
Merge pull request #82 from at-gmbh/feature/replay-hint
Browse files Browse the repository at this point in the history
hint user to correct invalid inputs in replay-file #57
  • Loading branch information
klamann authored Dec 8, 2022
2 parents b92ae6c + dab4bf9 commit f214011
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,22 @@
project_slug = '{{ cookiecutter.project_slug }}'
module_name = '{{ cookiecutter.module_name }}'

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

if not re.match(MODULE_REGEX, module_name):
print("ERROR: {} is not a valid Python module name! "
"See https://www.python.org/dev/peps/pep-0008/#package-and-module-names "
"for naming standards.".format(module_name))
invalid_inputs.append("module_name")

if invalid_inputs:
print("\nYou have entered invalid configuration values for: "
"{}".format(", ".join(invalid_inputs)))
print("\nPlease fix your inputs in ~/.cookiecutter_replay/at-python-template.json")
print("After that, rerun the template with: cookiecutter . --replay\n")
sys.exit(1)

0 comments on commit f214011

Please sign in to comment.