|
| 1 | +# CLI Interface |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The CLI interface provides command-line access to all code-lod operations using Typer. Each command is implemented in a separate module for maintainability. |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +### MUST |
| 10 | + |
| 11 | +- The system MUST provide commands: init, generate, status, validate, read, update, clean, config, hooks |
| 12 | +- Each command MUST be implemented in a separate file under `cli/` |
| 13 | +- The system MUST use Typer for command parsing and help text |
| 14 | +- The system MUST auto-detect the project root from the current directory |
| 15 | +- The system MUST provide clear error messages for common failure cases |
| 16 | + |
| 17 | +### Command Descriptions |
| 18 | + |
| 19 | +**init**: Initialize code-lod in a project directory |
| 20 | +- Creates `.code-lod` directory structure |
| 21 | +- Creates default `config.json` |
| 22 | + |
| 23 | +**generate**: Generate descriptions for code entities |
| 24 | +- Parses source files |
| 25 | +- Generates descriptions via LLM |
| 26 | +- Stores in database and `.lod` files |
| 27 | + |
| 28 | +**status**: Check freshness status of descriptions |
| 29 | +- Shows total, fresh, and stale counts |
| 30 | +- Lists stale entries |
| 31 | + |
| 32 | +**validate**: Validate descriptions |
| 33 | +- Checks for stale descriptions |
| 34 | +- Can fail with exit code 1 if stale entries found |
| 35 | + |
| 36 | +**read**: Output descriptions in LLM-consumable format |
| 37 | +- Retrieves descriptions from storage |
| 38 | +- Formats for LLM input |
| 39 | + |
| 40 | +**update**: Update stale descriptions |
| 41 | +- Regenerates only stale entries |
| 42 | +- Updates database and `.lod` files |
| 43 | + |
| 44 | +**clean**: Clean all code-lod data |
| 45 | +- Removes `.code-lod` directory |
| 46 | +- Removes all `.lod` files |
| 47 | + |
| 48 | +**config**: Configuration management |
| 49 | +- View and edit configuration |
| 50 | +- Set provider and model options |
| 51 | + |
| 52 | +**hooks**: Git hooks management |
| 53 | +- install: Install pre-commit hook |
| 54 | +- uninstall: Remove installed hooks |
| 55 | + |
| 56 | +### SHOULD |
| 57 | + |
| 58 | +- Commands SHOULD support common options (verbose, quiet, etc.) |
| 59 | +- Commands SHOULD provide helpful output for success and failure cases |
| 60 | + |
| 61 | +### MAY |
| 62 | + |
| 63 | +- The system MAY add additional commands in the future |
| 64 | +- The system MAY support shell completion for commands |
| 65 | + |
| 66 | +## Implementation |
| 67 | + |
| 68 | +### CLI Structure |
| 69 | + |
| 70 | +``` |
| 71 | +cli/ |
| 72 | +├── __init__.py # Main app registration |
| 73 | +├── init.py # Initialize code-lod |
| 74 | +├── generate.py # Generate descriptions |
| 75 | +├── status.py # Check freshness |
| 76 | +├── validate.py # Validate descriptions |
| 77 | +├── read.py # Output descriptions |
| 78 | +├── update.py # Update stale descriptions |
| 79 | +├── clean.py # Clean all data |
| 80 | +├── config.py # Configuration management |
| 81 | +└── hooks.py # Git hooks |
| 82 | +``` |
| 83 | + |
| 84 | +### Main App (`cli/__init__.py`) |
| 85 | + |
| 86 | +- Creates the main Typer app |
| 87 | +- Registers all sub-commands |
| 88 | +- Provides top-level help and version info |
| 89 | + |
| 90 | +### Command Pattern |
| 91 | + |
| 92 | +Each command module: |
| 93 | +- Defines one or more Typer functions |
| 94 | +- Uses `get_paths()` to find project root |
| 95 | +- Handles errors with appropriate exit codes |
| 96 | +- Provides user-friendly output via `typer.echo()` |
0 commit comments