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`. --- example/streaming-clap.zig | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'example/streaming-clap.zig') diff --git a/example/streaming-clap.zig b/example/streaming-clap.zig index 9ed38dd..a7ab7d8 100644 --- a/example/streaming-clap.zig +++ b/example/streaming-clap.zig @@ -3,6 +3,7 @@ const std = @import("std"); const debug = std.debug; const io = std.io; +const process = std.process; pub fn main() !void { const allocator = std.heap.page_allocator; @@ -21,16 +22,17 @@ pub fn main() !void { .{ .id = 'f', .takes_value = .one }, }; - // We then initialize an argument iterator. We will use the OsIterator as it nicely - // wraps iterating over arguments the most efficient way on each os. - var iter = try clap.args.OsIterator.init(allocator); + var iter = try process.ArgIterator.initWithAllocator(allocator); defer iter.deinit(); + // Skip exe argument + _ = iter.next(); + // Initalize our diagnostics, which can be used for reporting useful errors. // This is optional. You can also leave the `diagnostic` field unset if you // don't care about the extra information `Diagnostic` provides. var diag = clap.Diagnostic{}; - var parser = clap.StreamingClap(u8, clap.args.OsIterator){ + var parser = clap.StreamingClap(u8, process.ArgIterator){ .params = ¶ms, .iter = &iter, .diagnostic = &diag, -- cgit v1.2.3