From 7188a9fc85f6aa0f71a4cb7966f8b0a044f29e02 Mon Sep 17 00:00:00 2001 From: Jimmi Holst Christensen Date: Mon, 31 Jan 2022 17:11:15 +0100 Subject: Refactor the ArgIterator interface They now follow the interface provided by the standard library. This now means that we no longer needs `args.OsIterator` as that the one from `std` can now be used directly. Also remove `args.ShellIterator` as a simular iterator exists in `std` called `ArgIteratorGeneral`. --- clap/streaming.zig | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'clap/streaming.zig') diff --git a/clap/streaming.zig b/clap/streaming.zig index 3f24aaa..8eca51a 100644 --- a/clap/streaming.zig +++ b/clap/streaming.zig @@ -49,7 +49,7 @@ pub fn StreamingClap(comptime Id: type, comptime ArgIterator: type) type { .chaining => |state| return try parser.chaining(state), .rest_are_positional => { const param = parser.positionalParam() orelse unreachable; - const value = (try parser.iter.next()) orelse return null; + const value = parser.iter.next() orelse return null; return Arg(Id){ .param = param, .value = value }; }, } @@ -80,7 +80,7 @@ pub fn StreamingClap(comptime Id: type, comptime ArgIterator: type) type { if (maybe_value) |v| break :blk v; - break :blk (try parser.iter.next()) orelse + break :blk parser.iter.next() orelse return parser.err(arg, .{ .long = name }, error.MissingValue); }; @@ -99,7 +99,7 @@ pub fn StreamingClap(comptime Id: type, comptime ArgIterator: type) type { // arguments. if (mem.eql(u8, arg, "--")) { parser.state = .rest_are_positional; - const value = (try parser.iter.next()) orelse return null; + const value = parser.iter.next() orelse return null; return Arg(Id){ .param = param, .value = value }; } @@ -142,7 +142,7 @@ pub fn StreamingClap(comptime Id: type, comptime ArgIterator: type) type { } if (arg.len <= next_index) { - const value = (try parser.iter.next()) orelse + const value = parser.iter.next() orelse return parser.err(arg, .{ .short = short }, error.MissingValue); return Arg(Id){ .param = param, .value = value }; @@ -184,7 +184,7 @@ pub fn StreamingClap(comptime Id: type, comptime ArgIterator: type) type { }; fn parseNextArg(parser: *@This()) !?ArgInfo { - const full_arg = (try parser.iter.next()) orelse return null; + const full_arg = parser.iter.next() orelse return null; if (mem.eql(u8, full_arg, "--") or mem.eql(u8, full_arg, "-")) return ArgInfo{ .arg = full_arg, .kind = .positional }; if (mem.startsWith(u8, full_arg, "--")) -- cgit v1.2.3