diff --git a/cli/src/main.zig b/cli/src/main.zig index 088f79b..e3515a3 100644 --- a/cli/src/main.zig +++ b/cli/src/main.zig @@ -1,6 +1,13 @@ const std = @import("std"); const colors = @import("utils/colors.zig"); +// Handle unknown command - prints error and exits +fn handleUnknownCommand(cmd: []const u8) noreturn { + colors.printError("Unknown command: {s}\n", .{cmd}); + printUsage(); + std.process.exit(1); +} + pub fn main() !void { // Initialize colors based on environment colors.initColors(); @@ -31,7 +38,7 @@ pub fn main() !void { colors.printInfo("Setup configuration interactively\n", .{}); } else if (std.mem.eql(u8, command, "info")) { try @import("commands/info.zig").run(allocator, args[2..]); - }, + } else handleUnknownCommand(command), 'a' => if (std.mem.eql(u8, command, "annotate")) { try @import("commands/annotate.zig").run(allocator, args[2..]); }, @@ -46,7 +53,7 @@ pub fn main() !void { colors.printInfo("Sync project to server: {s}\n", .{args[2]}); } else if (std.mem.eql(u8, command, "status")) { try @import("commands/status.zig").run(allocator, args[2..]); - }, + } else handleUnknownCommand(command), 'r' => if (std.mem.eql(u8, command, "requeue")) { try @import("commands/requeue.zig").run(allocator, args[2..]); },