|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +hier-config-cli is a Click-based CLI tool for network configuration analysis built on the `hier-config` library. It compares running and intended device configs to generate remediation, rollback, and future-state configurations. Supports 10 network platforms (Cisco IOS/NXOS/XR, Arista EOS, Juniper JunOS, VyOS, FortiOS, HP Comware5/ProCurve, Generic). |
| 8 | + |
| 9 | +## Build & Development Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +# Install dependencies |
| 13 | +poetry install |
| 14 | + |
| 15 | +# Run all tests with coverage |
| 16 | +pytest |
| 17 | + |
| 18 | +# Run a single test |
| 19 | +pytest tests/test_cli.py::test_version |
| 20 | + |
| 21 | +# Code formatting |
| 22 | +black src/ tests/ |
| 23 | + |
| 24 | +# Linting |
| 25 | +ruff check src/ tests/ |
| 26 | + |
| 27 | +# Type checking |
| 28 | +mypy src/ |
| 29 | + |
| 30 | +# All quality checks |
| 31 | +black src/ tests/ && ruff check src/ tests/ && mypy src/ && pytest |
| 32 | +``` |
| 33 | + |
| 34 | +## Architecture |
| 35 | + |
| 36 | +The entire CLI lives in a single module: `src/hier_config_cli/__main__.py`. The entry point is the `cli()` Click group, registered as `hier-config-cli` in pyproject.toml. |
| 37 | + |
| 38 | +**Key flow:** All three config commands (`remediation`, `rollback`, `future`) share the same pattern: |
| 39 | +1. `common_options` decorator applies shared Click options (platform, running-config, generated-config, format, output) |
| 40 | +2. `process_configs()` validates the platform, reads both config files via `hier_config.utils.read_text_from_file`, parses them with `get_hconfig()`, then runs the requested operation via `WorkflowRemediation` (for remediation/rollback) or `HConfig.future()` (for future) |
| 41 | +3. `format_output()` converts the result HConfig to text/JSON/YAML |
| 42 | +4. `get_output_text()` handles platform-specific formatting — JunOS uses `line.text`, all others use `line.cisco_style_text()` |
| 43 | + |
| 44 | +**PLATFORM_MAP** dict maps CLI string names to `hier_config.Platform` enum values. To add a new platform, add it here, handle any special output formatting in `get_output_text()`, and add tests. |
| 45 | + |
| 46 | +## Code Standards |
| 47 | + |
| 48 | +- Python 3.10+ (uses `X | Y` union syntax) |
| 49 | +- Black formatter, 100-char line length |
| 50 | +- Ruff linter rules: E, W, F, I, B, C4, UP |
| 51 | +- mypy strict mode (all functions must have type hints) |
| 52 | +- Google-style docstrings |
| 53 | +- Conventional commits: `feat:`, `fix:`, `docs:`, `test:`, `refactor:` |
| 54 | + |
| 55 | +## Testing |
| 56 | + |
| 57 | +Tests use Click's `CliRunner` for CLI invocation testing. Fixtures provide mock Cisco IOS and Juniper JunOS configs via temporary files. The test suite covers all commands, output formats, all platforms, error handling, and logging levels. |
| 58 | + |
| 59 | +## CI/CD |
| 60 | + |
| 61 | +- `test-app.yaml`: Runs black, ruff, mypy, and pytest on Python 3.10–3.13 for every push/PR to main |
| 62 | +- `deploy.yaml`: Publishes to PyPI via Poetry on GitHub release creation |
| 63 | +- Version is maintained in both `pyproject.toml` and `__main__.py:__version__` |
0 commit comments