diff options
Diffstat (limited to 'src/shell.zig')
| -rw-r--r-- | src/shell.zig | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/shell.zig b/src/shell.zig index 5a848af..d3f75ec 100644 --- a/src/shell.zig +++ b/src/shell.zig @@ -20,11 +20,12 @@ pub fn executeCommand( append_output: ?[]const u8, append_error: ?[]const u8, history: *std.ArrayList([]const u8), + last_written_index: *usize, ) !builtins.CommandResult { if (std.mem.eql(u8, cmd_name, "exit")) return builtins.executeExit(); if (std.mem.eql(u8, cmd_name, "history")) { - // Check if args contain -r or -w flag for reading/writing file + // Check if args contain -r, -w, or -a flag for reading/writing/appending file if (args) |a| { const trimmed = std.mem.trim(u8, a, " "); if (std.mem.startsWith(u8, trimmed, "-r ")) { @@ -39,6 +40,12 @@ pub fn executeCommand( try builtins.executeHistoryWrite(stdout, file_path, history.items); } return .continue_loop; + } else if (std.mem.startsWith(u8, trimmed, "-a ")) { + const file_path = std.mem.trim(u8, trimmed[3..], " "); + if (file_path.len > 0) { + try builtins.executeHistoryAppend(stdout, file_path, history.items, last_written_index); + } + return .continue_loop; } } |