From cf4a6a89aae8a46bee84b542e33b735a05551dcf Mon Sep 17 00:00:00 2001 From: Alexei Samokvalov Date: Mon, 18 Dec 2023 09:02:32 +0100 Subject: [PATCH] Fix option lookup Closes #30 --- src/parser.zig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/parser.zig b/src/parser.zig index f41c860..64d0018 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -254,9 +254,8 @@ pub fn Parser(comptime Iterator: type) type { if (std.mem.eql(u8, "help", option_name)) { return &help_option; } - var ix = self.command_path.items.len - 1; - while (ix >= 0) : (ix -= 1) { - const cmd = self.command_path.items[ix]; + for (0..self.command_path.items.len) |ix| { + const cmd = self.command_path.items[self.command_path.items.len - ix - 1]; if (cmd.options) |option_list| { for (option_list) |option| { if (std.mem.eql(u8, option.long_name, option_name)) {