# Dosage - Zig Port This is a Zig port of the original Rust-based DOS command shell implementation. ## Dependency Replacements The original Rust version used several external crates that have been replaced with Zig standard library functionality: ### Rust → Zig Replacements - **`rustyline`** (command-line editing) → Simple `stdin.readUntilDelimiterOrEofAlloc()` - **`crossterm`** (terminal manipulation) → ANSI escape sequences for screen clearing - **`prettytable-rs`** (table formatting) → Custom formatting with `print()` - **`eyre`/`color-eyre`** (error handling) → Zig's built-in error handling - **`thiserror`** (error derive macros) → Zig error unions - **`regex`** (regular expressions) → Not needed in current implementation ### Key Architectural Changes 1. **Error Handling**: Replaced Rust's `Result` with Zig's error unions (`!T`) 2. **Memory Management**: Manual allocation/deallocation using Zig's allocators instead of Rust's ownership system 3. **String Handling**: Explicit memory management for strings vs Rust's `String`/`&str` 4. **Concurrency**: Removed complex threading from original Rust version for simplicity 5. **Command Line Editing**: Simplified to basic line reading (no history or editing features) ### Missing Features (compared to Rust version) - Command-line history and editing (rustyline features) - Colored error output - Advanced terminal manipulation - Complex pipe/redirection handling - Multi-threaded command execution ## Build Instructions ```bash # Build and run in debug mode zig build run # Build optimized release version zig build -Doptimize=ReleaseFast # Run tests zig build test ``` ## Implementation Notes The Zig version focuses on core DOS command functionality while maintaining the same architectural patterns as the Rust original. The enum-based command system has been preserved using Zig's union types. Key DOS commands implemented: - `ECHO` (with ON/OFF variants) - `CLS` (clear screen) - `EXIT` (exit shell) - `VER` (version info) - `DATE` and `TIME` (system date/time) - `DIR` (directory listing) The implementation uses Zig's standard library exclusively, avoiding external dependencies for better portability and simplicity.