From aa334d8c1df252f48960e0253eb25544678a6023 Mon Sep 17 00:00:00 2001 From: Komari Spaghetti Date: Mon, 26 Apr 2021 16:23:15 +0200 Subject: Refactor Diagnostic (and others) into a ParseOption struct This allows for default arguments, which we can also extend without breaking peoples code in the future. This is a breaking change right now though. --- example/simple-ex.zig | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'example/simple-ex.zig') diff --git a/example/simple-ex.zig b/example/simple-ex.zig index d6ecc44..f504d63 100644 --- a/example/simple-ex.zig +++ b/example/simple-ex.zig @@ -1,5 +1,5 @@ -const std = @import("std"); const clap = @import("clap"); +const std = @import("std"); const debug = std.debug; @@ -21,11 +21,13 @@ pub fn main() !void { defer iter.deinit(); // Initalize our diagnostics, which can be used for reporting useful errors. - // This is optional. You can also just pass `null` to `parser.next` if you - // don't care about the extra information `Diagnostics` provides. - var diag: clap.Diagnostic = undefined; - - var args = clap.parseEx(clap.Help, ¶ms, allocator, &iter, &diag) catch |err| { + // This is optional. You can also pass `.{}` to `clap.parse` if you don't + // care about the extra information `Diagnostics` provides. + var diag = clap.Diagnostic{}; + var args = clap.parseEx(clap.Help, ¶ms, &iter, .{ + .allocator = allocator, + .diagnostic = &diag, + }) catch |err| { // Report useful error and exit diag.report(std.io.getStdErr().outStream(), err) catch {}; return err; -- cgit v1.2.3