Skip to content

Commit ab8e9dd

Browse files
Copilottschm
andcommitted
Remove --language option from rhiza init CLI command
Co-authored-by: tschm <2046079+tschm@users.noreply.github.com>
1 parent 06457f9 commit ab8e9dd

3 files changed

Lines changed: 29 additions & 71 deletions

File tree

REPOSITORY_ANALYSIS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ Branch `copilot/add-early-repository-validation` contains a single "Initial plan
838838

839839
- **_sync_helpers.py at 958 LOC is the largest file and a potential maintenance bottleneck.** While the extraction (PR #319) improved test decoupling, the module is now 42% of the entire `src/rhiza/` codebase (2,259 total LOC). Consider further decomposition into `_diff.py`, `_merge.py`, `_lock_io.py`, and `_snapshot.py` if the file continues to grow.
840840

841-
- **No smoke test for Go language mode.** `rhiza init --language go` is supported (documented in CLI help text), but `.github/workflows/rhiza_smoke.yml` only tests the default Python mode. Go template initialization could silently break without detection. Add a second job to the smoke test workflow for Go projects.
841+
- **No smoke test for Go template repository mode.** Using `template_repository="jebel-quant/rhiza-go"` is supported, but `.github/workflows/rhiza_smoke.yml` only tests the default Python mode. Go template initialization could silently break without detection. Add a second job to the smoke test workflow for Go projects.
842842

843843
- **Pre-commit hook for custom rhiza checks uses external package.** `.pre-commit-config.yaml` references `rhiza-hooks>=0.3.0` (a separate PyPI package). If this package is unmaintained or has a breaking change, all pre-commit runs will fail. Consider vendoring critical hooks into `.rhiza/hooks/` or documenting the external dependency risk.
844844

@@ -936,7 +936,7 @@ This is an **exemplary production-grade project** with excellent engineering dis
936936

937937
- **_sync_helpers.py at 958 LOC is 42% of codebase and potential maintenance bottleneck.** While the extraction (PR #319) improved modularity, a single 958-line file concentrates critical logic. Consider further decomposition into focused modules: `_diff.py` (diff computation), `_merge.py` (3-way merge), `_lock_io.py` (lock file I/O with fcntl), `_snapshot.py` (template snapshot prep).
938938

939-
- **No smoke test for Go language mode.** `rhiza init --language go` is supported (visible in CLI help text and `language_validators.py`), but `rhiza_smoke.yml` only tests Python projects. Go template initialization could silently regress. Add second job to smoke test workflow for Go projects.
939+
- **No smoke test for Go template repository mode.** Using `template_repository="jebel-quant/rhiza-go"` is supported (visible in `language_validators.py`), but `rhiza_smoke.yml` only tests Python projects. Go template initialization could silently regress. Add second job to smoke test workflow for Go projects.
940940

941941
- **Pre-commit hooks depend on external rhiza-hooks package.** `.pre-commit-config.yaml` references `rhiza-hooks>=0.3.0` (separate PyPI package). If unmaintained or breaking, all pre-commit runs fail. Consider vendoring critical hooks into `.rhiza/hooks/` or documenting external dependency risk in CONTRIBUTING.md.
942942

src/rhiza/cli.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,10 @@ def init(
9999
help="Target Git hosting platform (github or gitlab). Determines which CI/CD files to include. "
100100
"If not provided, will prompt interactively.",
101101
),
102-
language: str = typer.Option(
103-
"python",
104-
"--language",
105-
help="Programming language for the project (python, go, etc.). Defaults to 'python'.",
106-
),
107102
template_repository: str = typer.Option(
108103
None,
109104
"--template-repository",
110-
help=(
111-
"Custom template repository (format: owner/repo). "
112-
"Defaults to 'jebel-quant/rhiza' for Python or 'jebel-quant/rhiza-go' for Go."
113-
),
105+
help=("Custom template repository (format: owner/repo). Defaults to 'jebel-quant/rhiza'."),
114106
),
115107
template_branch: str = typer.Option(
116108
None,
@@ -123,32 +115,25 @@ def init(
123115
Creates a default `.rhiza/template.yml` configuration file if one
124116
doesn't exist, or validates the existing configuration.
125117
126-
The default template includes common project files based on the language.
118+
The default template includes common project files.
127119
The --git-host option determines which CI/CD configuration to include:
128120
- github: includes .github folder (GitHub Actions workflows)
129121
- gitlab: includes .gitlab-ci.yml (GitLab CI configuration)
130122
131-
The --language option determines the project type and files created:
132-
- python: creates pyproject.toml, src/, and Python project structure
133-
- go: creates minimal structure (you'll need to run 'go mod init')
134-
135123
Examples:
136124
rhiza init
137-
rhiza init --language go
138-
rhiza init --language python --git-host github
139125
rhiza init --git-host gitlab
126+
rhiza init --git-host github
140127
rhiza init --template-repository myorg/my-templates
141128
rhiza init --template-repository myorg/my-templates --template-branch develop
142129
rhiza init /path/to/project
143-
rhiza init .. --language go
144130
"""
145131
if not init_cmd(
146132
target,
147133
project_name=project_name,
148134
package_name=package_name,
149135
with_dev_dependencies=with_dev_dependencies,
150136
git_host=git_host,
151-
language=language,
152137
template_repository=template_repository,
153138
template_branch=template_branch,
154139
):
Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Tests for language-specific init functionality."""
1+
"""Tests for template-repository-based init functionality."""
22

33
from unittest.mock import patch
44

@@ -7,42 +7,38 @@
77
from rhiza.commands.init import init
88

99

10-
class TestInitWithLanguage:
11-
"""Tests for init command with language parameter."""
10+
class TestInitWithTemplateRepository:
11+
"""Tests for init command with template repository selection."""
1212

13-
def test_init_with_go_language(self, tmp_path):
14-
"""Test that init with go language creates Go-specific structure."""
15-
init(tmp_path, git_host="github", language="go")
13+
@patch("rhiza.commands.init._check_template_repository_reachable", return_value=True)
14+
def test_init_with_go_template_repository(self, mock_check, tmp_path):
15+
"""Test that init with go template repository creates correct config."""
16+
init(tmp_path, git_host="github", template_repository="jebel-quant/rhiza-go")
1617

17-
# Verify template.yml was created with go language
18+
# Verify template.yml was created with go repository
1819
template_file = tmp_path / ".rhiza" / "template.yml"
1920
assert template_file.exists()
2021

2122
with open(template_file) as f:
2223
config = yaml.safe_load(f)
2324

2425
assert config["repository"] == "jebel-quant/rhiza-go"
25-
assert config["language"] == "go"
26-
27-
# Verify Go-specific structure was NOT created (user should run go mod init)
28-
assert not (tmp_path / "go.mod").exists()
29-
assert not (tmp_path / "src").exists()
30-
assert not (tmp_path / "pyproject.toml").exists()
31-
32-
# Only README should be created
33-
assert (tmp_path / "README.md").exists()
26+
# The language parameter defaults to "python" internally; RhizaTemplate.to_yaml()
27+
# omits the language field when it equals the default "python" value.
28+
assert "language" not in config
3429

35-
def test_init_with_python_language_explicit(self, tmp_path):
36-
"""Test that init with explicit python language creates Python structure."""
37-
init(tmp_path, git_host="github", language="python")
30+
def test_init_with_python_template_repository(self, tmp_path):
31+
"""Test that init with default python template repository creates Python structure."""
32+
init(tmp_path, git_host="github")
3833

3934
# Verify template.yml was created WITHOUT language field (it's default)
4035
template_file = tmp_path / ".rhiza" / "template.yml"
4136
with open(template_file) as f:
4237
config = yaml.safe_load(f)
4338

4439
assert config["repository"] == "jebel-quant/rhiza"
45-
# Language field should not be in config (it's the default)
40+
# RhizaTemplate.to_yaml() omits the language field when it equals the
41+
# default "python" value, so no language key is written to the file.
4642
assert "language" not in config
4743

4844
# Verify Python-specific structure
@@ -51,62 +47,39 @@ def test_init_with_python_language_explicit(self, tmp_path):
5147
assert (tmp_path / "README.md").exists()
5248

5349
def test_init_defaults_to_python(self, tmp_path):
54-
"""Test that init defaults to python when no language specified."""
50+
"""Test that init defaults to python when no template repository specified."""
5551
init(tmp_path, git_host="github")
5652

5753
# Verify Python structure was created
5854
assert (tmp_path / "pyproject.toml").exists()
5955
assert (tmp_path / "src").is_dir()
6056

6157
@patch("rhiza.commands.init._check_template_repository_reachable", return_value=True)
62-
def test_init_go_with_custom_template_repository(self, mock_check, tmp_path):
63-
"""Test that custom template repository works with Go language."""
58+
def test_init_with_custom_template_repository(self, mock_check, tmp_path):
59+
"""Test that custom template repository is stored correctly."""
6460
init(
6561
tmp_path,
6662
git_host="github",
67-
language="go",
6863
template_repository="custom/go-templates",
6964
)
7065

7166
template_file = tmp_path / ".rhiza" / "template.yml"
7267
with open(template_file) as f:
7368
config = yaml.safe_load(f)
7469

75-
# Custom repository should override default
70+
# Custom repository should be set
7671
assert config["repository"] == "custom/go-templates"
77-
assert config["language"] == "go"
78-
79-
def test_init_unknown_language(self, tmp_path):
80-
"""Test that init handles unknown languages gracefully."""
81-
init(tmp_path, git_host="github", language="rust")
82-
83-
# Should create minimal structure
84-
assert (tmp_path / ".rhiza" / "template.yml").exists()
85-
assert (tmp_path / "README.md").exists()
8672

87-
# Should not create language-specific files
88-
assert not (tmp_path / "pyproject.toml").exists()
89-
assert not (tmp_path / "go.mod").exists()
90-
91-
# Verify template.yml
92-
template_file = tmp_path / ".rhiza" / "template.yml"
93-
with open(template_file) as f:
94-
config = yaml.safe_load(f)
95-
96-
assert config["language"] == "rust"
97-
# Should use default Python repository since no mapping exists
98-
assert config["repository"] == "jebel-quant/rhiza"
99-
100-
def test_init_go_language_with_gitlab(self, tmp_path):
101-
"""Test Go init with GitLab hosting."""
102-
init(tmp_path, git_host="gitlab", language="go")
73+
@patch("rhiza.commands.init._check_template_repository_reachable", return_value=True)
74+
def test_init_go_template_repository_with_gitlab(self, mock_check, tmp_path):
75+
"""Test go template repository with GitLab hosting."""
76+
init(tmp_path, git_host="gitlab", template_repository="jebel-quant/rhiza-go")
10377

10478
template_file = tmp_path / ".rhiza" / "template.yml"
10579
with open(template_file) as f:
10680
config = yaml.safe_load(f)
10781

10882
assert config["repository"] == "jebel-quant/rhiza-go"
109-
assert config["language"] == "go"
11083
# Should include gitlab in templates
11184
assert "gitlab" in config["templates"]
11285
assert "github" not in config["templates"]

0 commit comments

Comments
 (0)