This directory contains the refactored, modular CLI for the MLSysBook project. The CLI has been broken down from a monolithic 4000+ line script into maintainable, testable modules.
cli/
├── __init__.py # Package initialization
├── main.py # Main CLI application class
├── core/ # Core functionality
│ ├── config.py # Configuration management
│ └── discovery.py # Chapter/file discovery
├── commands/ # Command implementations
│ └── build.py # Build operations
├── formats/ # Format-specific handlers (future)
└── utils/ # Shared utilities (future)
- Manages Quarto configuration files for HTML, PDF, and EPUB
- Handles symlink creation and switching between formats
- Provides output directory detection from config files
- Discovers and validates chapter files
- Supports fuzzy matching for chapter names
- Provides chapter listing and dependency detection
- Handles build operations for all formats
- Supports both full book and individual chapter builds
- Includes progress indication and error handling
- Main application class that orchestrates all components
- Provides command routing and help system
- Beautiful Rich-based UI with organized command tables
The modular CLI has replaced the original binder and is available as ./binder in the project root:
# Show help
./binder help
# Build commands
./binder build # Build full book (HTML)
./binder build intro,ml_systems # Build specific chapters (HTML)
./binder pdf intro # Build chapter as PDF
./binder epub # Build full book as EPUB
# Preview commands
./binder preview # Start live dev server for full book
./binder preview intro # Start live dev server for chapter
# Management
./binder list # List all chapters
./binder status # Show current status
./binder doctor # Run comprehensive health check- Maintainability: Each component has a single responsibility
- Testability: Individual modules can be unit tested
- Debuggability: Issues can be isolated to specific modules
- Extensibility: New formats and commands are easy to add
- Code Reuse: Shared functionality is properly modularized
- Collaboration: Multiple developers can work on different components
The modular CLI has successfully replaced the original monolithic binder script:
./binder- Modular CLI (4000+ lines → organized modules)
All functionality has been preserved and enhanced:
- All existing commands work the same way
- Same configuration files and output directories
- Same build processes and quality
- Enhanced error handling and progress indication
- New preview and doctor commands added
The modular architecture enables easy addition of:
- Format-specific handlers in
formats/ - Additional commands in
commands/ - Shared utilities in
utils/ - Plugin system for custom extensions
- Comprehensive unit test suite