diff options
Diffstat (limited to 'src/syntax.zig')
-rw-r--r-- | src/syntax.zig | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/syntax.zig b/src/syntax.zig index af4833c..0725859 100644 --- a/src/syntax.zig +++ b/src/syntax.zig @@ -603,6 +603,33 @@ const Parser = struct { } const path = try self.allocator.dupe(u8, args.items[0]); return Command{ .Builtin = BuiltinCommand{ .Mkdir = .{ .path = path } } }; + } else if (std.mem.eql(u8, cmd_upper, "RD") or std.mem.eql(u8, cmd_upper, "RMDIR")) { + if (args.items.len == 0) { + return error.ExpectedWord; // Will show "Bad command or file name" + } + const path = try self.allocator.dupe(u8, args.items[0]); + return Command{ .Builtin = BuiltinCommand{ .Rmdir = .{ .path = path } } }; + } else if (std.mem.eql(u8, cmd_upper, "REN") or std.mem.eql(u8, cmd_upper, "RENAME")) { + if (args.items.len < 2) { + return error.ExpectedWord; // Will show "Bad command or file name" + } + const from_spec = try parseFilespec(self.allocator, args.items[0]); + const to_spec = try parseFilespec(self.allocator, args.items[1]); + return Command{ .Builtin = BuiltinCommand{ .Rename = .{ .from = from_spec, .to = to_spec } } }; + } else if (std.mem.eql(u8, cmd_upper, "MOVE")) { + // MOVE command is more complex - for now just show not implemented + return Command{ .Builtin = BuiltinCommand.Move }; + } else if (std.mem.eql(u8, cmd_upper, "PATH")) { + if (args.items.len == 0) { + return Command{ .Builtin = BuiltinCommand.PathGet }; + } else { + // PATH=value or PATH value + const value = if (std.mem.startsWith(u8, args.items[0], "=")) + try self.allocator.dupe(u8, args.items[0][1..]) // Skip the '=' + else + try self.allocator.dupe(u8, args.items[0]); + return Command{ .Builtin = BuiltinCommand{ .PathSet = .{ .value = value } } }; + } } else { // External command - need to duplicate all strings const program_copy = try self.allocator.dupe(u8, command_name); |