Skip to content

Commit 13044e8

Browse files
committed
Multiselect project type, fix project_slug bug
1 parent 2764be9 commit 13044e8

File tree

3 files changed

+32
-35
lines changed

3 files changed

+32
-35
lines changed

copier-helper.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ uvx copier copy --defaults --force --trust \
1313
--data email="hello@switch.box" \
1414
--data author_github_handle="switchbox-data" \
1515
--data project_name="example-project" \
16-
--data project_slug="example_project" \
1716
--data project_description="Example" \
18-
--data python_data_science="y" \
19-
--data python_package="y" \
20-
--data r_data_science="n" \
17+
--data project_features="[python_data_science, python_package]" \
2118
--data use_github="y" \
2219
--data open_source_license="MIT license" \
2320
--data aws="n" \

copier.yml

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ project_name:
2727

2828
project_slug:
2929
type: str
30-
default: "[[ project_name|lower|replace('-', '_') ]]"
31-
help: Importable Python package name
30+
default: "{{ project_name|lower|replace('-', '_') }}"
31+
when: false
3232

3333
project_description:
3434
type: str
@@ -40,23 +40,15 @@ type_checker:
4040
default: "ty"
4141
when: "{{ python == 'y' }}"
4242

43-
python_data_science:
44-
type: str
45-
choices: ["y", "n"]
46-
default: "y"
47-
help: "Include Python data science tools (polars, pyarrow, seaborn, numpy, quarto, notebooks) - At least one of: python_data_science, python_package, or r_data_science must be selected"
48-
49-
python_package:
43+
project_features:
5044
type: str
51-
choices: ["y", "n"]
52-
default: "y"
53-
help: "Include Python package publishing tools (build, twine, mkdocs documentation) - At least one of: python_data_science, python_package, or r_data_science must be selected"
54-
55-
r_data_science:
56-
type: str
57-
choices: ["y", "n"]
58-
default: "n"
59-
help: "Include R data science tools (R, renv, Quarto, R extensions) - At least one of: python_data_science, python_package, or r_data_science must be selected"
45+
multiselect: true
46+
choices:
47+
- python_data_science
48+
- python_package
49+
- r_data_science
50+
default: [python_data_science, python_package]
51+
help: "Select project features (use space to select/deselect, enter to confirm)"
6052

6153
use_github:
6254
type: str
@@ -83,7 +75,23 @@ aws:
8375
# Computed variables
8476
python:
8577
type: str
86-
default: "{{ 'y' if (python_data_science == 'y' or python_package == 'y') else 'n' }}"
78+
default: "{{ 'y' if ('python_data_science' in project_features or 'python_package' in project_features) else 'n' }}"
79+
when: false
80+
81+
# Backward compatibility computed variables
82+
python_data_science:
83+
type: str
84+
default: "{{ 'y' if 'python_data_science' in project_features else 'n' }}"
85+
when: false
86+
87+
python_package:
88+
type: str
89+
default: "{{ 'y' if 'python_package' in project_features else 'n' }}"
90+
when: false
91+
92+
r_data_science:
93+
type: str
94+
default: "{{ 'y' if 'r_data_science' in project_features else 'n' }}"
8795
when: false
8896

8997
# Post-generation tasks

tests/test_template.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ def test_python_data_science(tmp_path: Path) -> None:
3838
"email": "hello@switch.box",
3939
"author_github_handle": "switchbox-data",
4040
"project_name": "py-proj",
41-
"project_slug": "py_proj",
4241
"project_description": "Test py",
4342
"type_checker": "ty",
44-
"python_data_science": "y",
45-
"python_package": "n",
43+
"project_features": "[python_data_science]",
4644
"use_github": "y",
4745
"open_source_license": "MIT license",
4846
"aws": "y",
@@ -73,10 +71,8 @@ def test_python_minimal(tmp_path: Path) -> None:
7371
"email": "hello@switch.box",
7472
"author_github_handle": "switchbox-data",
7573
"project_name": "minimal-proj",
76-
"project_slug": "minimal_proj",
7774
"project_description": "Minimal Python project",
78-
"python_data_science": "y",
79-
"python_package": "n",
75+
"project_features": "[python_data_science]",
8076
"use_github": "n",
8177
"open_source_license": "MIT license",
8278
"aws": "n",
@@ -107,10 +103,8 @@ def test_no_python_features(tmp_path: Path) -> None:
107103
"email": "hello@switch.box",
108104
"author_github_handle": "switchbox-data",
109105
"project_name": "no-python-proj",
110-
"project_slug": "no_python_proj",
111106
"project_description": "Project with no Python features",
112-
"python_data_science": "n",
113-
"python_package": "n",
107+
"project_features": "[]",
114108
"use_github": "y",
115109
"open_source_license": "MIT license",
116110
"aws": "n",
@@ -133,11 +127,9 @@ def test_python_mkdocs_only(tmp_path: Path) -> None:
133127
"email": "hello@switch.box",
134128
"author_github_handle": "switchbox-data",
135129
"project_name": "docs-proj",
136-
"project_slug": "docs_proj",
137130
"project_description": "Docs only",
138131
"type_checker": "mypy",
139-
"python_data_science": "n",
140-
"python_package": "y",
132+
"project_features": "[python_package]",
141133
"use_github": "y",
142134
"open_source_license": "MIT license",
143135
"aws": "n",

0 commit comments

Comments
 (0)