Skip to content

Conversation

@jamesobutler
Copy link
Contributor

This closes #102.

Per https://cookiecutter.readthedocs.io/en/stable/advanced/hooks.html#examples:

A pre_gen_project hook can validate template variables.

I have used this method to return an exit failure if an app_name is provided with anything other than alphanumeric characters.

  [1/12] project_name (SlicerCustomAppTemplate): 3D Slicer
  [2/12] github_organization (Kitware):
  [3/12] github_project (3D Slicer):
  [4/12] org_domain (kitware.com):
  [5/12] org_name (Kitware, Inc.):
  [6/12] app_name (3D Slicer):
  [7/12] bundle_identifier (com.kitware.3d slicer):
  [8/12] app_version_major (0):
  [9/12] app_version_minor (1):
  [10/12] app_version_patch (0):
  [11/12] app_description_summary (Customized version of Slicer):
  [12/12] cdash_drop_site (open.cdash.org):
ERROR: 3D Slicer is not a valid app name. Only alphanumeric characters are allowed.
ERROR: Stopping generation because pre_gen_project hook script didn't exit successfully
Hook script failed (exit status: 1)

@jcfr
Copy link
Collaborator

jcfr commented Sep 18, 2025

🙏 for the patch. This is also a great improvement 💯

Could you check that the following also work:

@jamesobutler
Copy link
Contributor Author

jamesobutler commented Sep 18, 2025

Using the same type inputs as in the original issue report of #19, I'm unable to replicate on Windows when using this branch. I haven't tried with current main,

PS C:\D> cookiecutter gh:jamesobutler/SlicerCustomAppTemplate -c app-name-validation
You've downloaded C:\Users\butlej30383\.cookiecutters\SlicerCustomAppTemplate before. Is it okay to delete and
re-download it? [y/n] (y): Y
  [1/12] project_name (SlicerCustomAppTemplate): aevaSlicer
  [2/12] github_organization (Kitware):
  [3/12] github_project (aevaSlicer): aevaSlicer
  [4/12] org_domain (kitware.com):
  [5/12] org_name (Kitware, Inc.):
  [6/12] app_name (aevaSlicer): aevaSlicer
  [7/12] bundle_identifier (com.kitware.aevaslicer):
  [8/12] app_version_major (0):
  [9/12] app_version_minor (1):
  [10/12] app_version_patch (0):
  [11/12] app_description_summary (Customized version of Slicer):
  [12/12] cdash_drop_site (open.cdash.org):
PS C:\D> python --version
Python 3.12.10
PS C:\D> cookiecutter --version
Cookiecutter 2.6.0 from C:\Users\butlej30383\AppData\Local\Programs\Python\Python312\Lib\site-packages (Python 3.12.10 (tags/v3.12.10:0cc8128, Apr  8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)])
PS C:\D>

@jcfr jcfr merged commit 0182521 into KitwareMedical:main Sep 18, 2025
3 checks passed
@jamesobutler jamesobutler deleted the app-name-validation branch September 18, 2025 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to configure project with name that contains a space

2 participants