Skip to content

feat: Add --path-to-template option to rhiza validate and rhiza init#442

Merged
HarryCampion merged 3 commits intomainfrom
copilot/add-custom-paths-for-templates
Mar 13, 2026
Merged

feat: Add --path-to-template option to rhiza validate and rhiza init#442
HarryCampion merged 3 commits intomainfrom
copilot/add-custom-paths-for-templates

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 13, 2026

rhiza validate and rhiza init always resolved template.yml from <TARGET>/.rhiza/, with no way to point them at a custom location — unlike rhiza sync, which already supports --path-to-template for this purpose.

Changes

  • src/rhiza/cli.py — Added --path-to-template option to both the validate and init commands. Mirrors the existing sync implementation: constructs template_file = path_to_template / "template.yml" and passes it through to the underlying command function.

  • src/rhiza/commands/init.py — Extended _create_template_file() and init() with an optional template_file parameter. When provided, template.yml is written to that path (with parent directories auto-created) instead of the default <target>/.rhiza/template.yml. Added a _display_path() helper to format file paths in log messages. The final validate() call also uses the custom path.

  • tests/test_commands/test_validate.py — Three new CLI-level tests in TestValidateCustomTemplatePath: custom directory succeeds, missing file exits non-zero, and template in project root.

  • tests/test_commands/test_init.py — New TestInitCustomTemplatePath class with tests covering: custom directory creation, nested parent directory creation, prompt-skip when custom file already exists, and CLI wiring.

  • README.md / CLI.md — Updated rhiza validate and rhiza init docs to include the new option and usage examples.

Usage

# Validate using a custom template directory
rhiza validate --path-to-template /custom/rhiza

# Init with template.yml in a custom directory
rhiza init --path-to-template /custom/rhiza

# Template lives in project root rather than .rhiza/
rhiza validate --path-to-template .
rhiza init --path-to-template .
Original prompt

This section details on the original issue you should resolve

<issue_title>rhiza validate should also allow custom paths for templates like sync</issue_title>
<issue_description>see #439 & #440 </issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: HarryCampion <40582604+HarryCampion@users.noreply.github.com>
Copilot AI changed the title [WIP] [RHIZA-439] Validate allowing custom paths for templates Add --path-to-template option to rhiza validate Mar 13, 2026
Copilot AI requested a review from HarryCampion March 13, 2026 09:47
@HarryCampion
Copy link
Copy Markdown
Collaborator

@copilot I think the same concept will have to be applied to the init functionality too.

Co-authored-by: HarryCampion <40582604+HarryCampion@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 13, 2026

@copilot I think the same concept will have to be applied to the init functionality too.

Done in 734c791. rhiza init now accepts --path-to-template <directory> to control where template.yml is created (defaults to <TARGET>/.rhiza as before). The underlying init() and _create_template_file() functions also accept an explicit template_file path, mirroring the same pattern used by sync and validate.

Copilot AI changed the title Add --path-to-template option to rhiza validate Add --path-to-template option to rhiza validate and rhiza init Mar 13, 2026
@HarryCampion HarryCampion changed the title Add --path-to-template option to rhiza validate and rhiza init feat: Add --path-to-template option to rhiza validate and rhiza init Mar 13, 2026
@HarryCampion HarryCampion marked this pull request as ready for review March 13, 2026 10:16
@HarryCampion HarryCampion merged commit 08ef849 into main Mar 13, 2026
15 checks passed
@HarryCampion HarryCampion deleted the copilot/add-custom-paths-for-templates branch March 13, 2026 10:17
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.

rhiza validate should also allow custom paths for templates like sync

2 participants