mirror of
https://github.com/shokinn/hosts-go.git
synced 2025-08-23 16:43:02 +00:00
- Added `internal/core/parser.go` for parsing hosts files, including: - Support for standard entries (IPv4, IPv6, multiple aliases, inline comments) - Handling of comments and disabled entries - Error recovery for malformed lines with warnings - Intelligent formatting with adaptive spacing and column alignment - Backup and atomic write operations for file safety test(parser): Add comprehensive tests for hosts file parsing - Created `tests/parser_test.go` with 54 test cases covering: - Standard entries and comments - Malformed lines and whitespace variations - Round-trip parsing to ensure format preservation - Backup functionality for hosts files docs(progress): Update project progress and next steps - Mark Phase 1 as complete and outline tasks for Phase 2 (TUI implementation) - Highlight completed features and testing coverage
71 lines
3.3 KiB
Markdown
71 lines
3.3 KiB
Markdown
# Product Context: hosts-go
|
|
|
|
## Why This Project Exists
|
|
|
|
The `/etc/hosts` file is a critical system file that maps hostnames to IP addresses, but managing it manually is cumbersome and error-prone. Users currently face several pain points:
|
|
|
|
- **Manual editing**: Requires opening `/etc/hosts` in a text editor with sudo privileges
|
|
- **Format preservation**: Easy to accidentally break formatting or lose comments
|
|
- **Entry management**: No easy way to temporarily disable entries without deleting them
|
|
- **DNS resolution**: Manual IP address updates when hostnames change
|
|
- **Organization**: No built-in sorting or reordering capabilities
|
|
|
|
## Problems It Solves
|
|
|
|
1. **Safe editing**: Provides a structured interface that validates changes before writing
|
|
2. **Entry activation**: Toggle entries on/off without losing the configuration
|
|
3. **Organization**: Sort and reorder entries intuitively
|
|
4. **DNS integration**: Automatically resolve hostnames to current IP addresses
|
|
5. **Comment preservation**: Maintain documentation alongside entries
|
|
6. **Permission handling**: Only request sudo access when actually editing
|
|
|
|
## How It Should Work
|
|
|
|
### Core User Experience
|
|
- **View mode by default**: Browse entries safely without modification risk
|
|
- **Explicit edit mode**: Clear transition to editing with permission request
|
|
- **Two-pane interface**: List view + detail view for efficient navigation
|
|
- **Keyboard-driven**: Fast navigation and actions via keyboard shortcuts
|
|
- **Visual feedback**: Clear indicators for active/inactive entries and changes
|
|
|
|
### Key Workflows
|
|
|
|
1. **Browse entries**: Launch app, see all current hosts entries with status
|
|
2. **Quick activation**: Toggle entries on/off with simple keypress
|
|
3. **Edit existing**: Select entry, enter edit mode, modify details
|
|
4. **Add new**: Create new hostname mappings with validation
|
|
5. **DNS resolution**: Update IP addresses automatically from DNS
|
|
6. **Reorder entries**: Drag/move entries to organize logically
|
|
|
|
## User Experience Goals
|
|
|
|
### Immediate Value
|
|
- **Zero learning curve**: Intuitive interface familiar to CLI users
|
|
- **Safety first**: Hard to accidentally break the hosts file
|
|
- **Speed**: Faster than manual editing for common tasks
|
|
|
|
### Long-term Benefits
|
|
- **Organized hosts**: Keep entries structured and documented
|
|
- **Confidence**: Know changes are validated before applied
|
|
- **Efficiency**: Common tasks become single keystrokes
|
|
|
|
### Target Users
|
|
- **Developers**: Managing local development environments
|
|
- **System administrators**: Bulk hosts file management
|
|
- **Network engineers**: Testing connectivity and DNS overrides
|
|
- **Security professionals**: Blocking/redirecting malicious domains
|
|
|
|
## Success Metrics
|
|
- Users prefer this tool over manual `/etc/hosts` editing
|
|
- Reduces hosts file corruption incidents
|
|
- Speeds up common host management tasks
|
|
- Provides confidence in making changes
|
|
|
|
## Phase 1 Achievements ✅
|
|
- **Safety foundation**: Backup system and atomic writes prevent any data loss
|
|
- **Format preservation**: Intelligent parser maintains user formatting preferences
|
|
- **Comprehensive validation**: IP and hostname validation with clear error messages
|
|
- **Error resilience**: Warning system handles malformed entries gracefully
|
|
- **Production ready**: 54 comprehensive tests covering all edge cases and scenarios
|
|
|
|
The core value proposition of safe, reliable hosts file management has been fully implemented and validated.
|