summaryrefslogtreecommitdiff
path: root/example/streaming-clap.zig
diff options
context:
space:
mode:
Diffstat (limited to 'example/streaming-clap.zig')
-rw-r--r--example/streaming-clap.zig11
1 files changed, 10 insertions, 1 deletions
diff --git a/example/streaming-clap.zig b/example/streaming-clap.zig
index b92a9e6..941070f 100644
--- a/example/streaming-clap.zig
+++ b/example/streaming-clap.zig
@@ -34,8 +34,17 @@ pub fn main() !void {
34 .iter = &iter, 34 .iter = &iter,
35 }; 35 };
36 36
37 // Initalize our diagnostics, which can be used for reporting useful errors.
38 // This is optional. You can also just pass `null` to `parser.next` if you
39 // don't care about the extra information `Diagnostics` provides.
40 var diag: clap.Diagnostic = undefined;
41
37 // Because we use a streaming parser, we have to consume each argument parsed individually. 42 // Because we use a streaming parser, we have to consume each argument parsed individually.
38 while (try parser.next()) |arg| { 43 while (parser.next(&diag) catch |err| {
44 // Report useful error and exit
45 diag.report(std.io.getStdErr().outStream(), err) catch {};
46 return err;
47 }) |arg| {
39 // arg.param will point to the parameter which matched the argument. 48 // arg.param will point to the parameter which matched the argument.
40 switch (arg.param.id) { 49 switch (arg.param.id) {
41 'h' => debug.warn("Help!\n", .{}), 50 'h' => debug.warn("Help!\n", .{}),