summaryrefslogtreecommitdiff
path: root/README-ZIG.md
blob: d965cd66d709e7ef76bc2e51ae9a0766bce2d1b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Dose - 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<T, E>` 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.