rhiza 0.4.0__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rhiza-0.5.0/.github/copilot-instructions.md +349 -0
- rhiza-0.5.0/CLI.md +311 -0
- rhiza-0.5.0/PKG-INFO +773 -0
- rhiza-0.5.0/README.md +740 -0
- rhiza-0.5.0/USAGE.md +638 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/pyproject.toml +1 -1
- {rhiza-0.4.0 → rhiza-0.5.0}/src/rhiza/__init__.py +4 -0
- rhiza-0.5.0/src/rhiza/cli.py +115 -0
- rhiza-0.5.0/src/rhiza/commands/init.py +66 -0
- rhiza-0.4.0/src/rhiza/commands/inject.py → rhiza-0.5.0/src/rhiza/commands/materialize.py +14 -34
- rhiza-0.5.0/src/rhiza/commands/validate.py +140 -0
- rhiza-0.5.0/src/rhiza/models.py +103 -0
- rhiza-0.5.0/tests/test_cli_commands.py +112 -0
- rhiza-0.5.0/tests/test_commands/test_init.py +105 -0
- rhiza-0.4.0/tests/test_cli_commands.py → rhiza-0.5.0/tests/test_commands/test_materialize.py +70 -210
- rhiza-0.5.0/tests/test_commands/test_validate.py +356 -0
- rhiza-0.5.0/tests/test_models.py +183 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/uv.lock +1 -1
- rhiza-0.4.0/PKG-INFO +0 -35
- rhiza-0.4.0/README.md +0 -2
- rhiza-0.4.0/src/rhiza/cli.py +0 -47
- rhiza-0.4.0/src/rhiza/commands/hello.py +0 -9
- {rhiza-0.4.0 → rhiza-0.5.0}/.editorconfig +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/actions/setup-project/action.yml +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/renovate.json +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/scripts/book.sh +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/scripts/bump.sh +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/scripts/customisations/build-extras.sh +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/scripts/customisations/post-release.sh +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/scripts/marimushka.sh +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/scripts/release.sh +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/scripts/sync.sh +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/scripts/update-readme-help.sh +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/template.yml +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/workflows/book.yml +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/workflows/ci.yml +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/workflows/deptry.yml +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/workflows/marimo.yml +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/workflows/pre-commit.yml +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/workflows/release.yml +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/workflows/scripts/version_matrix.py +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/workflows/scripts/version_max.py +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/workflows/structure.yml +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.github/workflows/sync.yml +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.gitignore +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/.pre-commit-config.yaml +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/CODE_OF_CONDUCT.md +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/CONTRIBUTING.md +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/LICENSE +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/Makefile +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/book/marimo/.gitkeep +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/pytest.ini +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/ruff.toml +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/src/rhiza/__main__.py +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/src/rhiza/commands/__init__.py +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/tests/test_rhiza/README.md +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/tests/test_rhiza/conftest.py +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/tests/test_rhiza/test_bump_script.py +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/tests/test_rhiza/test_docstrings.py +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/tests/test_rhiza/test_git_repo_fixture.py +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/tests/test_rhiza/test_makefile.py +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/tests/test_rhiza/test_marimushka_script.py +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/tests/test_rhiza/test_readme.py +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/tests/test_rhiza/test_release_script.py +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/tests/test_rhiza/test_structure.py +0 -0
- {rhiza-0.4.0 → rhiza-0.5.0}/tests/test_rhiza/test_updatereadme_script.py +0 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
# GitHub Copilot Instructions for rhiza-cli
|
|
2
|
+
|
|
3
|
+
## Project Overview
|
|
4
|
+
|
|
5
|
+
Rhiza is a command-line interface (CLI) tool for managing reusable configuration templates for modern Python projects. It provides commands for initializing, validating, and materializing configuration templates across projects.
|
|
6
|
+
|
|
7
|
+
**Repository:** <https://github.com/jebel-quant/rhiza-cli>
|
|
8
|
+
|
|
9
|
+
## Technology Stack
|
|
10
|
+
|
|
11
|
+
- **Language:** Python 3.11+ (supports 3.11, 3.12, 3.13, 3.14)
|
|
12
|
+
- **Package Manager:** uv (fast Python package installer and resolver)
|
|
13
|
+
- **CLI Framework:** Typer
|
|
14
|
+
- **Testing:** pytest with coverage reporting
|
|
15
|
+
- **Linting/Formatting:** Ruff
|
|
16
|
+
- **Build System:** Hatchling
|
|
17
|
+
- **Pre-commit Hooks:** YAML/TOML validation, Ruff, markdownlint, actionlint
|
|
18
|
+
|
|
19
|
+
## Project Structure
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
rhiza-cli/
|
|
23
|
+
├── src/rhiza/ # Main source code
|
|
24
|
+
│ ├── cli.py # CLI entry points (Typer app)
|
|
25
|
+
│ └── commands/ # Command implementations
|
|
26
|
+
├── tests/ # Test suite
|
|
27
|
+
├── book/ # Documentation and Marimo notebooks
|
|
28
|
+
├── .github/ # GitHub workflows and scripts
|
|
29
|
+
├── pyproject.toml # Project configuration
|
|
30
|
+
├── ruff.toml # Linting configuration
|
|
31
|
+
└── Makefile # Development tasks
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Coding Standards
|
|
35
|
+
|
|
36
|
+
### Python Style
|
|
37
|
+
|
|
38
|
+
- **Line length:** Maximum 120 characters
|
|
39
|
+
- **Quotes:** Use double quotes for strings
|
|
40
|
+
- **Indentation:** 4 spaces (no tabs)
|
|
41
|
+
- **Docstrings:** Google style convention (required for all public modules, classes, and functions)
|
|
42
|
+
- **Type hints:** Not strictly enforced but encouraged
|
|
43
|
+
- **Import sorting:** Automatic via isort (part of Ruff)
|
|
44
|
+
|
|
45
|
+
### Linting Rules
|
|
46
|
+
|
|
47
|
+
The project uses Ruff with the following rule sets:
|
|
48
|
+
|
|
49
|
+
- **D** (pydocstyle): Docstring style enforcement
|
|
50
|
+
- **E** (pycodestyle): PEP 8 style guide errors
|
|
51
|
+
- **F** (pyflakes): Logical error detection
|
|
52
|
+
- **I** (isort): Import sorting
|
|
53
|
+
- **N** (pep8-naming): PEP 8 naming conventions
|
|
54
|
+
- **W** (pycodestyle): PEP 8 warnings
|
|
55
|
+
- **UP** (pyupgrade): Modern Python syntax
|
|
56
|
+
|
|
57
|
+
**Exception:** Tests allow assert statements (S101 ignored in tests/)
|
|
58
|
+
|
|
59
|
+
### Docstring Requirements
|
|
60
|
+
|
|
61
|
+
- All public modules, classes, functions, and methods must have docstrings
|
|
62
|
+
- Use Google docstring convention
|
|
63
|
+
- Include magic methods like `__init__` (D105, D107 enforced)
|
|
64
|
+
- Use multi-line format with summary line, then blank line, then details
|
|
65
|
+
|
|
66
|
+
Example:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
def my_function(arg1: str, arg2: int) -> bool:
|
|
70
|
+
"""Short summary of what the function does.
|
|
71
|
+
|
|
72
|
+
Longer description if needed. Explain complex behavior,
|
|
73
|
+
side effects, or important context.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
arg1: Description of arg1
|
|
77
|
+
arg2: Description of arg2
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
Description of return value (bool)
|
|
81
|
+
"""
|
|
82
|
+
return True
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Development Workflow
|
|
86
|
+
|
|
87
|
+
### Setup
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
make install # Install dependencies with uv
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Common Commands
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
make fmt # Run linters and formatters (pre-commit)
|
|
97
|
+
make test # Run tests with coverage
|
|
98
|
+
make docs # Generate documentation with pdoc
|
|
99
|
+
make clean # Clean build artifacts
|
|
100
|
+
make help # Show all available commands
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Testing
|
|
104
|
+
|
|
105
|
+
- Use pytest for all tests
|
|
106
|
+
- Place tests in `tests/` directory
|
|
107
|
+
- Test files should match pattern `test_*.py`
|
|
108
|
+
- Aim for good coverage of new code
|
|
109
|
+
- Run tests with `make test` before submitting changes
|
|
110
|
+
|
|
111
|
+
### Pre-commit Hooks
|
|
112
|
+
|
|
113
|
+
The project uses pre-commit hooks that run automatically on commit:
|
|
114
|
+
|
|
115
|
+
- YAML/TOML validation
|
|
116
|
+
- Ruff linting and formatting
|
|
117
|
+
- Markdown linting (MD013 disabled for long lines)
|
|
118
|
+
- GitHub workflow validation
|
|
119
|
+
- Renovate config validation
|
|
120
|
+
- README.md auto-update with Makefile help
|
|
121
|
+
|
|
122
|
+
## Architecture Notes
|
|
123
|
+
|
|
124
|
+
### CLI Structure
|
|
125
|
+
|
|
126
|
+
The CLI uses Typer for command definitions. Commands are thin wrappers in `cli.py` that delegate to implementations in `rhiza.commands.*`:
|
|
127
|
+
|
|
128
|
+
- `init`: Initialize or validate `.github/template.yml`
|
|
129
|
+
- `materialize` (alias `inject`): Apply templates to a target repository
|
|
130
|
+
- `validate`: Validate template configuration
|
|
131
|
+
|
|
132
|
+
### Command Implementation Pattern
|
|
133
|
+
|
|
134
|
+
1. Command defined in `src/rhiza/cli.py` using Typer decorators
|
|
135
|
+
2. Implementation logic in `src/rhiza/commands/*.py`
|
|
136
|
+
3. Commands use `loguru` for logging
|
|
137
|
+
4. Use `Path` from `pathlib` for file operations
|
|
138
|
+
|
|
139
|
+
## Best Practices
|
|
140
|
+
|
|
141
|
+
1. **Minimal changes:** Make surgical, focused changes
|
|
142
|
+
2. **Type hints:** Use when they improve clarity
|
|
143
|
+
3. **Error handling:** Use appropriate exceptions, log errors clearly
|
|
144
|
+
4. **Documentation:** Update docstrings when changing function signatures
|
|
145
|
+
5. **Tests:** Add tests for new functionality
|
|
146
|
+
6. **Imports:** Keep imports organized (isort handles this automatically)
|
|
147
|
+
7. **File headers:** Include repository attribution comment at top of new files:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
# This file is part of the jebel-quant/rhiza repository
|
|
151
|
+
# (https://github.com/jebel-quant/rhiza).
|
|
152
|
+
#
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Dependencies
|
|
156
|
+
|
|
157
|
+
### Core Dependencies
|
|
158
|
+
|
|
159
|
+
See `pyproject.toml` for exact versions. Key dependencies:
|
|
160
|
+
|
|
161
|
+
- `typer` - CLI framework
|
|
162
|
+
- `loguru` - Logging
|
|
163
|
+
- `PyYAML` - YAML parsing
|
|
164
|
+
|
|
165
|
+
### Development Dependencies
|
|
166
|
+
|
|
167
|
+
See `pyproject.toml` for complete list. Key dev dependencies:
|
|
168
|
+
|
|
169
|
+
- `pytest`, `pytest-cov`, `pytest-html` - Testing
|
|
170
|
+
- `pre-commit` - Git hooks
|
|
171
|
+
- `marimo` - Notebook support
|
|
172
|
+
- `pdoc` - Documentation generation
|
|
173
|
+
|
|
174
|
+
## Common Patterns
|
|
175
|
+
|
|
176
|
+
### Path Handling
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from pathlib import Path
|
|
180
|
+
|
|
181
|
+
target = Path(".") # Use Path objects, not strings
|
|
182
|
+
if target.exists():
|
|
183
|
+
# Do something
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Logging
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from loguru import logger
|
|
190
|
+
|
|
191
|
+
logger.info("Starting operation")
|
|
192
|
+
logger.error("Something went wrong")
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### CLI Arguments
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
import typer
|
|
199
|
+
|
|
200
|
+
@app.command()
|
|
201
|
+
def my_command(
|
|
202
|
+
target: Path = typer.Argument(
|
|
203
|
+
default=Path("."),
|
|
204
|
+
exists=True,
|
|
205
|
+
help="Description"
|
|
206
|
+
),
|
|
207
|
+
):
|
|
208
|
+
"""Command docstring."""
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Security Considerations
|
|
212
|
+
|
|
213
|
+
- **No secrets in code:** Never commit API keys, passwords, or sensitive data
|
|
214
|
+
- **Path traversal:** Always use `Path.resolve()` to normalize paths and prevent directory traversal attacks
|
|
215
|
+
- **Input validation:** Validate all user inputs, especially file paths and command arguments
|
|
216
|
+
- **YAML parsing:** Use safe YAML loading (PyYAML uses safe loading by default)
|
|
217
|
+
- **File permissions:** Be mindful of file permissions when creating files
|
|
218
|
+
|
|
219
|
+
## Error Handling Patterns
|
|
220
|
+
|
|
221
|
+
### Exception Handling
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
from loguru import logger
|
|
225
|
+
from pathlib import Path
|
|
226
|
+
|
|
227
|
+
def safe_operation(path: Path):
|
|
228
|
+
"""Safe operation with proper error handling."""
|
|
229
|
+
try:
|
|
230
|
+
# Normalize path to prevent traversal
|
|
231
|
+
path = path.resolve()
|
|
232
|
+
|
|
233
|
+
if not path.exists():
|
|
234
|
+
logger.error(f"Path does not exist: {path}")
|
|
235
|
+
raise FileNotFoundError(f"Path not found: {path}")
|
|
236
|
+
|
|
237
|
+
# Perform operation
|
|
238
|
+
return True
|
|
239
|
+
|
|
240
|
+
except PermissionError as e:
|
|
241
|
+
logger.error(f"Permission denied: {e}")
|
|
242
|
+
raise
|
|
243
|
+
except Exception as e:
|
|
244
|
+
logger.error(f"Unexpected error: {e}")
|
|
245
|
+
raise
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### CLI Exit Codes
|
|
249
|
+
|
|
250
|
+
Use Typer's `Exit` for non-zero exit codes on errors:
|
|
251
|
+
|
|
252
|
+
```python
|
|
253
|
+
import typer
|
|
254
|
+
|
|
255
|
+
if not success:
|
|
256
|
+
raise typer.Exit(code=1)
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Common Tasks
|
|
260
|
+
|
|
261
|
+
### Adding a New Command
|
|
262
|
+
|
|
263
|
+
1. Create a new file in `src/rhiza/commands/` (e.g., `newcommand.py`)
|
|
264
|
+
2. Implement the command logic with proper docstrings
|
|
265
|
+
3. Add a wrapper in `src/rhiza/cli.py` using Typer decorators
|
|
266
|
+
4. Add tests in `tests/` for the new command
|
|
267
|
+
5. Update documentation if needed
|
|
268
|
+
|
|
269
|
+
Example:
|
|
270
|
+
|
|
271
|
+
```python
|
|
272
|
+
# In src/rhiza/commands/newcommand.py
|
|
273
|
+
from pathlib import Path
|
|
274
|
+
from loguru import logger
|
|
275
|
+
|
|
276
|
+
def my_new_command(target: Path):
|
|
277
|
+
"""Execute the new command.
|
|
278
|
+
|
|
279
|
+
Parameters
|
|
280
|
+
----------
|
|
281
|
+
target:
|
|
282
|
+
Path to the target directory.
|
|
283
|
+
"""
|
|
284
|
+
target = target.resolve()
|
|
285
|
+
logger.info(f"Running new command on: {target}")
|
|
286
|
+
# Implementation here
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
```python
|
|
290
|
+
# In src/rhiza/cli.py
|
|
291
|
+
from rhiza.commands.newcommand import my_new_command
|
|
292
|
+
|
|
293
|
+
@app.command()
|
|
294
|
+
def newcommand(
|
|
295
|
+
target: Path = typer.Argument(
|
|
296
|
+
default=Path("."),
|
|
297
|
+
exists=True,
|
|
298
|
+
file_okay=False,
|
|
299
|
+
dir_okay=True,
|
|
300
|
+
help="Target directory"
|
|
301
|
+
),
|
|
302
|
+
):
|
|
303
|
+
"""Short description of the command."""
|
|
304
|
+
my_new_command(target)
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Running the CLI in Development
|
|
308
|
+
|
|
309
|
+
```bash
|
|
310
|
+
# Install in editable mode
|
|
311
|
+
make install
|
|
312
|
+
|
|
313
|
+
# Run the CLI
|
|
314
|
+
uv run rhiza --help
|
|
315
|
+
uv run rhiza init
|
|
316
|
+
uv run rhiza materialize --branch main
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## Troubleshooting
|
|
320
|
+
|
|
321
|
+
### Common Issues
|
|
322
|
+
|
|
323
|
+
**Import errors after adding dependencies:**
|
|
324
|
+
- Run `make install` to sync dependencies
|
|
325
|
+
- Ensure `pyproject.toml` is updated with new dependencies
|
|
326
|
+
|
|
327
|
+
**Linting failures:**
|
|
328
|
+
- Run `make fmt` to auto-fix most issues
|
|
329
|
+
- Check `ruff.toml` for configured rules
|
|
330
|
+
- Ensure docstrings follow Google convention
|
|
331
|
+
|
|
332
|
+
**Test failures:**
|
|
333
|
+
- Run `make test` to see detailed output
|
|
334
|
+
- Check test coverage report in `_tests/html-coverage/`
|
|
335
|
+
- Ensure new code has corresponding tests
|
|
336
|
+
|
|
337
|
+
**Pre-commit hook failures:**
|
|
338
|
+
- Run `make fmt` to fix formatting issues
|
|
339
|
+
- Check `.pre-commit-config.yaml` for hook configuration
|
|
340
|
+
- Install hooks with `uv run pre-commit install`
|
|
341
|
+
|
|
342
|
+
## When Making Changes
|
|
343
|
+
|
|
344
|
+
1. Run `make fmt` to ensure code follows style guidelines
|
|
345
|
+
2. Run `make test` to verify tests pass
|
|
346
|
+
3. Update docstrings if changing public APIs
|
|
347
|
+
4. Add tests for new functionality
|
|
348
|
+
5. Keep changes focused and minimal
|
|
349
|
+
6. Follow existing code patterns and conventions
|
rhiza-0.5.0/CLI.md
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# Rhiza CLI Quick Reference
|
|
2
|
+
|
|
3
|
+
This document provides a quick reference for the Rhiza command-line interface.
|
|
4
|
+
|
|
5
|
+
## Command Overview
|
|
6
|
+
|
|
7
|
+
| Command | Description |
|
|
8
|
+
|---------|-------------|
|
|
9
|
+
| `rhiza init` | Initialize or validate `.github/template.yml` |
|
|
10
|
+
| `rhiza materialize` | Inject templates into a target repository |
|
|
11
|
+
| `rhiza validate` | Validate template configuration |
|
|
12
|
+
|
|
13
|
+
## Common Usage Patterns
|
|
14
|
+
|
|
15
|
+
### First-time setup
|
|
16
|
+
```bash
|
|
17
|
+
cd your-project
|
|
18
|
+
rhiza init
|
|
19
|
+
rhiza materialize
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Update templates
|
|
23
|
+
```bash
|
|
24
|
+
rhiza materialize --force
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Validate before committing
|
|
28
|
+
```bash
|
|
29
|
+
rhiza validate && git add . && git commit
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Command Details
|
|
33
|
+
|
|
34
|
+
### rhiza init
|
|
35
|
+
|
|
36
|
+
**Purpose:** Create or validate `.github/template.yml`
|
|
37
|
+
|
|
38
|
+
**Syntax:**
|
|
39
|
+
```bash
|
|
40
|
+
rhiza init [TARGET]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Parameters:**
|
|
44
|
+
- `TARGET` - Directory to initialize (default: current directory)
|
|
45
|
+
|
|
46
|
+
**Examples:**
|
|
47
|
+
```bash
|
|
48
|
+
rhiza init # Initialize current directory
|
|
49
|
+
rhiza init /path/to/project # Initialize specific directory
|
|
50
|
+
rhiza init .. # Initialize parent directory
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### rhiza materialize
|
|
56
|
+
|
|
57
|
+
**Purpose:** Copy template files into your project
|
|
58
|
+
|
|
59
|
+
**Syntax:**
|
|
60
|
+
```bash
|
|
61
|
+
rhiza materialize [OPTIONS] [TARGET]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Parameters:**
|
|
65
|
+
- `TARGET` - Target repository directory (default: current directory)
|
|
66
|
+
|
|
67
|
+
**Options:**
|
|
68
|
+
- `--branch, -b <branch>` - Template branch to use (default: main)
|
|
69
|
+
- `--force, -y` - Overwrite existing files without prompting
|
|
70
|
+
|
|
71
|
+
**Examples:**
|
|
72
|
+
```bash
|
|
73
|
+
rhiza materialize # Basic usage
|
|
74
|
+
rhiza materialize --branch develop # Use develop branch
|
|
75
|
+
rhiza materialize --force # Overwrite existing files
|
|
76
|
+
rhiza materialize /path/to/project -b v2.0 # Specific directory and branch
|
|
77
|
+
rhiza materialize -b main -y # Short form
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Behavior:**
|
|
81
|
+
- Creates `.github/template.yml` if it doesn't exist
|
|
82
|
+
- Performs sparse clone of template repository
|
|
83
|
+
- Copies only specified files/directories
|
|
84
|
+
- Respects exclude patterns
|
|
85
|
+
- Skips existing files unless `--force` is used
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### rhiza validate
|
|
90
|
+
|
|
91
|
+
**Purpose:** Validate `.github/template.yml` configuration
|
|
92
|
+
|
|
93
|
+
**Syntax:**
|
|
94
|
+
```bash
|
|
95
|
+
rhiza validate [TARGET]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Parameters:**
|
|
99
|
+
- `TARGET` - Repository directory to validate (default: current directory)
|
|
100
|
+
|
|
101
|
+
**Exit Codes:**
|
|
102
|
+
- `0` - Validation passed
|
|
103
|
+
- `1` - Validation failed
|
|
104
|
+
|
|
105
|
+
**Examples:**
|
|
106
|
+
```bash
|
|
107
|
+
rhiza validate # Validate current directory
|
|
108
|
+
rhiza validate /path/to/project # Validate specific directory
|
|
109
|
+
rhiza validate .. # Validate parent directory
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Validation Checks:**
|
|
113
|
+
- ✓ File exists
|
|
114
|
+
- ✓ Valid YAML syntax
|
|
115
|
+
- ✓ Required fields present
|
|
116
|
+
- ✓ Field types correct
|
|
117
|
+
- ✓ Repository format (owner/repo)
|
|
118
|
+
- ✓ Include list not empty
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Configuration File Reference
|
|
123
|
+
|
|
124
|
+
### Location
|
|
125
|
+
`.github/template.yml`
|
|
126
|
+
|
|
127
|
+
### Format
|
|
128
|
+
```yaml
|
|
129
|
+
# Required: Template repository (owner/repo format)
|
|
130
|
+
template-repository: jebel-quant/rhiza
|
|
131
|
+
|
|
132
|
+
# Optional: Branch to use (default: main)
|
|
133
|
+
template-branch: main
|
|
134
|
+
|
|
135
|
+
# Required: Files/directories to include
|
|
136
|
+
include:
|
|
137
|
+
- .github
|
|
138
|
+
- .editorconfig
|
|
139
|
+
- .gitignore
|
|
140
|
+
- Makefile
|
|
141
|
+
|
|
142
|
+
# Optional: Files/directories to exclude
|
|
143
|
+
exclude:
|
|
144
|
+
- .github/workflows/deploy.yml
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Field Reference
|
|
148
|
+
|
|
149
|
+
| Field | Type | Required | Description |
|
|
150
|
+
|-------|------|----------|-------------|
|
|
151
|
+
| `template-repository` | string | Yes | GitHub repo in `owner/repo` format |
|
|
152
|
+
| `template-branch` | string | No | Branch name (default: `main`) |
|
|
153
|
+
| `include` | list | Yes | Paths to copy from template |
|
|
154
|
+
| `exclude` | list | No | Paths to skip when copying |
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Tips and Best Practices
|
|
159
|
+
|
|
160
|
+
### Shell Completion
|
|
161
|
+
|
|
162
|
+
Enable shell completion for tab completion of commands:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Install completion
|
|
166
|
+
rhiza --install-completion
|
|
167
|
+
|
|
168
|
+
# Show completion script
|
|
169
|
+
rhiza --show-completion
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Using with Git
|
|
173
|
+
|
|
174
|
+
Add to your git workflow:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Before making changes
|
|
178
|
+
rhiza validate || exit 1
|
|
179
|
+
|
|
180
|
+
# Update templates periodically
|
|
181
|
+
git checkout -b update-templates
|
|
182
|
+
rhiza materialize --force
|
|
183
|
+
git diff # Review changes
|
|
184
|
+
git commit -am "chore: update rhiza templates"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### CI/CD Integration
|
|
188
|
+
|
|
189
|
+
Add validation to your CI pipeline:
|
|
190
|
+
|
|
191
|
+
```yaml
|
|
192
|
+
# .github/workflows/validate.yml
|
|
193
|
+
- name: Validate Rhiza config
|
|
194
|
+
run: |
|
|
195
|
+
pip install rhiza
|
|
196
|
+
rhiza validate
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Multiple Template Repositories
|
|
200
|
+
|
|
201
|
+
While Rhiza doesn't directly support multiple template repositories, you can:
|
|
202
|
+
|
|
203
|
+
1. Create separate template.yml files
|
|
204
|
+
2. Rename and use them sequentially:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# Use different templates
|
|
208
|
+
cp .github/template-base.yml .github/template.yml
|
|
209
|
+
rhiza materialize --force
|
|
210
|
+
|
|
211
|
+
cp .github/template-testing.yml .github/template.yml
|
|
212
|
+
rhiza materialize --force
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Debugging
|
|
216
|
+
|
|
217
|
+
Enable verbose output with Python logging:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Set log level to DEBUG
|
|
221
|
+
export LOGURU_LEVEL=DEBUG
|
|
222
|
+
rhiza materialize
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
View what git operations are happening:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Watch git commands
|
|
229
|
+
GIT_TRACE=1 rhiza materialize
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Common Issues
|
|
235
|
+
|
|
236
|
+
### "Command not found: rhiza"
|
|
237
|
+
|
|
238
|
+
**Solution:** Ensure rhiza is installed and in your PATH:
|
|
239
|
+
```bash
|
|
240
|
+
pip install --user rhiza
|
|
241
|
+
export PATH="$HOME/.local/bin:$PATH"
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### "Target directory is not a git repository"
|
|
245
|
+
|
|
246
|
+
**Solution:** Initialize git first:
|
|
247
|
+
```bash
|
|
248
|
+
git init
|
|
249
|
+
rhiza init
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### "Template file not found"
|
|
253
|
+
|
|
254
|
+
**Solution:** Run init first:
|
|
255
|
+
```bash
|
|
256
|
+
rhiza init
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Files not being copied
|
|
260
|
+
|
|
261
|
+
**Checklist:**
|
|
262
|
+
- [ ] Paths in `include` are correct
|
|
263
|
+
- [ ] Paths exist in template repository
|
|
264
|
+
- [ ] Not filtered by `exclude` patterns
|
|
265
|
+
- [ ] Using `--force` if files already exist
|
|
266
|
+
|
|
267
|
+
### Clone fails during materialize
|
|
268
|
+
|
|
269
|
+
**Possible causes:**
|
|
270
|
+
- Repository doesn't exist or is private
|
|
271
|
+
- Branch doesn't exist
|
|
272
|
+
- No network connectivity
|
|
273
|
+
- Git credentials not configured for private repos
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## Environment Variables
|
|
278
|
+
|
|
279
|
+
| Variable | Description | Default |
|
|
280
|
+
|----------|-------------|---------|
|
|
281
|
+
| `LOGURU_LEVEL` | Logging level (DEBUG, INFO, WARNING, ERROR) | INFO |
|
|
282
|
+
|
|
283
|
+
---
|
|
284
|
+
|
|
285
|
+
## Getting Help
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# Main help
|
|
289
|
+
rhiza --help
|
|
290
|
+
|
|
291
|
+
# Command-specific help
|
|
292
|
+
rhiza init --help
|
|
293
|
+
rhiza materialize --help
|
|
294
|
+
rhiza validate --help
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## Version Information
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
# Check installed version
|
|
303
|
+
pip show rhiza
|
|
304
|
+
|
|
305
|
+
# Upgrade to latest
|
|
306
|
+
pip install --upgrade rhiza
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
For detailed documentation, see [README.md](README.md)
|