const std = @import("std"); const command = @import("command"); const cmd = command.executeName; var commands: Commands = undefined; pub fn init() !void { var v: void = {}; try commands.init(&v); } pub fn deinit() void { commands.deinit(); } const Commands = command.Collection(cmds_); const cmds_ = struct { pub const Target = void; const Ctx = command.Context; const Result = command.Result; pub fn w(_: *void, _: Ctx) Result { try cmd("save_file", .{}); } pub const w_meta = .{ .description = "w (write file)" }; pub fn q(_: *void, _: Ctx) Result { try cmd("quit", .{}); } pub const q_meta = .{ .description = "q (quit)" }; pub fn @"q!"(_: *void, _: Ctx) Result { try cmd("quit_without_saving", .{}); } pub const @"q!_meta" = .{ .description = "q! (quit without saving)" }; pub fn wq(_: *void, _: Ctx) Result { try cmd("save_file", command.fmt(.{ "then", .{ "quit", .{} } })); } pub const wq_meta = .{ .description = "wq (write file and quit)" }; pub fn o(_: *void, _: Ctx) Result { try cmd("open_file", .{}); } pub const o_meta = .{ .description = "o (open file)" }; pub fn @"wq!"(_: *void, _: Ctx) Result { cmd("save_file", .{}) catch {}; try cmd("quit_without_saving", .{}); } pub const @"wq!_meta" = .{ .description = "wq! (write file and quit without saving)" }; };