Skip to content

Feat/cli#74

Merged
houfu merged 2 commits into
mainfrom
feat/cli
Oct 15, 2025
Merged

Feat/cli#74
houfu merged 2 commits into
mainfrom
feat/cli

Conversation

@houfu
Copy link
Copy Markdown
Owner

@houfu houfu commented Oct 15, 2025

Fixes #61

houfu and others added 2 commits October 15, 2025 10:38
Enhanced the CLI with comprehensive new features:

**File Input Support:**
- All commands now accept both file paths and string literals
- Smart detection with proper UTF-8 encoding handling
- Graceful error handling for encoding issues and permissions

**New Output Formats:**
- `json` command: Output comparison results as JSON with --pretty flag
- `stats` command: Display comprehensive statistics with --quiet flag

**Enhanced Existing Commands:**
- `text`: Added stats panel at bottom and --quiet flag support
- `markdown`: Added --quiet flag for raw markdown output
- `simple_text`: Added file input support and exit codes

**Exit Code Strategy (ALL commands):**
- 0: Success with changes detected
- 1: Success with no changes (source == test)
- 2: Error (file not found, encoding issues, etc.)

**Helper Functions:**
- `_read_input()`: Smart file/string reader with error handling
- `_format_stats_panel()`: Format statistics as Rich panel
- `_set_exit_code()`: Consistent exit code handling

**Testing:**
- Added 35 comprehensive tests in tests/test_cli.py
- Tests cover all commands, file handling, exit codes, and edge cases
- All 93 tests pass successfully

**Documentation:**
- Updated CLI docstring with all new features and examples
- Added file input examples, exit code documentation
- Documented all flags and options

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Added proper type annotations to all test functions and fixtures in
test_cli.py to satisfy mypy type checking:

- Added return type annotations (-> None) to all test methods
- Added parameter type annotations (CliRunner, Path, dict[str, Path])
- Added typing.Any import for future extensibility

All 35 CLI tests still pass with full type safety.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@houfu houfu merged commit 63f098e into main Oct 15, 2025
10 checks passed
@houfu houfu deleted the feat/cli branch October 15, 2025 06:58
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.

Enhance CLI for agent-friendly usage

1 participant