const std = @import("std"); const Allocator = std.mem.Allocator; const types = @import("./lib/types.zig"); const CommandStatus = types.CommandStatus; const CommandContext = types.CommandContext; pub const EchoOff = struct { pub fn eval(echo_off: EchoOff, ctx: CommandContext) !CommandStatus { _ = echo_off; _ = ctx; return CommandStatus{ .Code = 0 }; } }; pub const EchoOn = struct { pub fn eval(echo_on: EchoOn, ctx: CommandContext) !CommandStatus { _ = echo_on; const output = "ECHO is on\n"; var writer = ctx.output_writer; try writer.write(output); return CommandStatus{ .Code = 0 }; } }; pub const EchoPlain = struct { pub fn eval(echo_plain: EchoPlain, ctx: CommandContext) !CommandStatus { _ = echo_plain; const output = "ECHO is on\n"; var writer = ctx.output_writer; try writer.write(output); return CommandStatus{ .Code = 0 }; } }; pub const EchoText = struct { message: []const u8, pub fn eval(echo_text: EchoText, ctx: CommandContext) !CommandStatus { const output = try std.fmt.allocPrint(ctx.allocator, "{s}\n", .{echo_text.message}); defer ctx.allocator.free(output); var writer = ctx.output_writer; try writer.write(output); return CommandStatus{ .Code = 0 }; } };