diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2025-08-13 20:04:04 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2025-08-13 20:04:04 +0200 |
commit | 51a9d99310bff6df8f92963613595a69ec778991 (patch) | |
tree | d34629d86b253c78bedddc49ceea4c08a9bf2aa1 /IMPLEMENTATION_PLAN.md | |
parent | ae87986ddfe6d93a3cff2b78fee5db62c775bd9a (diff) |
Add implementation plan for most commonly used commands.
Diffstat (limited to 'IMPLEMENTATION_PLAN.md')
-rw-r--r-- | IMPLEMENTATION_PLAN.md | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/IMPLEMENTATION_PLAN.md b/IMPLEMENTATION_PLAN.md new file mode 100644 index 0000000..c8f8681 --- /dev/null +++ b/IMPLEMENTATION_PLAN.md @@ -0,0 +1,195 @@ +# DOS Command Implementation Plan + +## Overview +This document outlines the plan to implement the most commonly used DOS commands that are currently missing from the dosage shell implementation. + +## Implementation Priority + +### Phase 1: Core File/Directory Operations (High Priority) + +#### 1. CD/CHDIR - Change Directory +- **Status**: Not implemented +- **Priority**: High (Essential for navigation) +- **Implementation**: + - Update parser to recognize `CD` and `CHDIR` commands + - Add `Chdir` variant handling in eval.zig + - Use `std.fs.cwd().setDir()` or equivalent + - Handle relative and absolute paths + - Support `CD..` (parent directory) + - Support `CD\` (root directory) + - Update current working directory tracking in main loop + +#### 2. COPY - Copy Files +- **Status**: Not implemented +- **Priority**: High (Most common file operation) +- **Implementation**: + - Add parsing for `COPY source dest` syntax + - Handle FileSpec sources and destinations (files, CON, devices) + - Implement file-to-file copying with `std.fs.copyFile()` + - Support wildcard copying (*.txt, etc.) + - Handle overwrite prompts and `/Y` switch + - Support copying to/from devices like CON + +#### 3. DEL/ERASE - Delete Files +- **Status**: Not implemented +- **Priority**: High (Essential file operation) +- **Implementation**: + - Add parsing for `DEL` and `ERASE` commands + - Support wildcard deletion (*.bak, etc.) + - Implement confirmation prompts + - Use `std.fs.deleteFile()` for single files + - Use directory iteration for wildcards + - Handle access denied and file not found errors + +#### 4. MD/MKDIR - Create Directory +- **Status**: Not implemented +- **Priority**: High (Essential for file organization) +- **Implementation**: + - Add parsing for `MD` and `MKDIR` commands + - Use `std.fs.cwd().makeDir()` + - Handle nested directory creation + - Provide appropriate error messages for existing directories + +#### 5. SET - Environment Variables +- **Status**: Not implemented +- **Priority**: Medium (Important for shell functionality) +- **Implementation**: + - Add global environment variable storage (HashMap) + - Support `SET` (display all variables) + - Support `SET VAR=value` (set variable) + - Support `SET VAR` (display single variable) + - Integrate with external command execution + - Handle special variables like PATH, PROMPT + +### Phase 2: Extended File Operations (Medium Priority) + +#### 6. RD/RMDIR - Remove Directory +- **Status**: Not implemented +- **Priority**: Medium +- **Implementation**: + - Add parsing for `RD` and `RMDIR` commands + - Use `std.fs.cwd().deleteDir()` + - Handle non-empty directory errors + - Support `/S` switch for recursive deletion + +#### 7. REN/RENAME - Rename Files/Directories +- **Status**: Not implemented +- **Priority**: Medium +- **Implementation**: + - Add parsing for `REN oldname newname` syntax + - Use `std.fs.cwd().rename()` + - Support wildcard renaming + - Handle cross-drive moves (convert to copy+delete) + +#### 8. MOVE - Move Files/Directories +- **Status**: Not implemented +- **Priority**: Medium +- **Implementation**: + - Add parsing for `MOVE source dest` syntax + - Try rename first, fallback to copy+delete for cross-filesystem moves + - Support directory moving + - Handle overwrite confirmation + +#### 9. PATH - Command Search Path +- **Status**: Not implemented +- **Priority**: Medium +- **Implementation**: + - Support `PATH` (display current path) + - Support `PATH=directory;directory2` (set path) + - Integrate with external command resolution + - Store in environment variables + +### Phase 3: Utility Commands (Low Priority) + +#### 10. PROMPT - Command Prompt Customization +- **Status**: Not implemented +- **Priority**: Low +- **Implementation**: + - Support `PROMPT` (display current prompt) + - Support `PROMPT text$G` (set prompt format) + - Implement prompt codes ($P=path, $G=>, $N=drive, etc.) + - Integrate with main shell loop + +#### 11. MORE - Paged Output Display +- **Status**: Not implemented +- **Priority**: Low +- **Implementation**: + - Implement paging with screen height detection + - Support "Press any key to continue" prompts + - Handle pipe input for `command | MORE` + - Add /S switch for squashing blank lines + +#### 12. FIND - Text Search in Files +- **Status**: Not implemented +- **Priority**: Low +- **Implementation**: + - Add parsing for `FIND "text" filename` syntax + - Support /I switch for case-insensitive search + - Support /V switch for non-matching lines + - Support /N switch for line numbers + - Handle multiple files and wildcards + +#### 13. TREE - Directory Tree Display +- **Status**: Not implemented +- **Priority**: Low +- **Implementation**: + - Implement recursive directory traversal + - Create tree-like ASCII art display + - Support /F switch for showing files + - Support /A switch for ASCII characters only + +#### 14. ATTRIB - File Attributes +- **Status**: Not implemented +- **Priority**: Low +- **Implementation**: + - Display file attributes (R/H/S/A) + - Support setting/clearing attributes + - Use platform-specific attribute APIs + - Handle wildcards for multiple files + +#### 15. VOL - Volume Information +- **Status**: Not implemented +- **Priority**: Low +- **Implementation**: + - Display volume label and serial number + - Use filesystem stat APIs + - Handle different drive specifications + +## Implementation Guidelines + +### Code Organization +- Add command parsing to `src/syntax.zig` in the `parseBuiltinCommand()` function +- Add command execution to `src/eval.zig` in the builtin command switch +- Update `BuiltinCommand` enum variants as needed +- Maintain DOS-authentic error messages and behavior + +### Error Handling +- Use DOS-style error messages ("File not found", "Access denied", etc.) +- Return appropriate exit codes (0 for success, 1+ for errors) +- Handle edge cases gracefully (missing arguments, invalid paths, etc.) + +### Testing Strategy +- Test each command with valid and invalid arguments +- Test with various file types and permissions +- Test error conditions and edge cases +- Verify DOS-authentic behavior and output format + +### Cross-Platform Considerations +- Use Zig standard library APIs for maximum portability +- Handle path separators correctly (DOS uses backslash) +- Consider case sensitivity differences between platforms +- Test on both Unix-like and Windows systems + +## Dependencies and Prerequisites +- Current codebase with working parser and evaluator +- Zig standard library filesystem APIs +- Basic I/O redirection support (already implemented) +- Error handling infrastructure (already in place) + +## Estimated Implementation Effort +- Phase 1 (High Priority): ~3-4 days of development +- Phase 2 (Medium Priority): ~2-3 days of development +- Phase 3 (Low Priority): ~3-4 days of development +- **Total**: ~8-11 days for complete implementation + +This plan provides a roadmap for transforming the dosage shell from a basic command interpreter into a fully functional DOS-style environment with comprehensive file and directory management capabilities.
\ No newline at end of file |