summaryrefslogtreecommitdiff
path: root/example/simple.zig
diff options
context:
space:
mode:
Diffstat (limited to 'example/simple.zig')
-rw-r--r--example/simple.zig14
1 files changed, 7 insertions, 7 deletions
diff --git a/example/simple.zig b/example/simple.zig
index 559bba6..69473fa 100644
--- a/example/simple.zig
+++ b/example/simple.zig
@@ -1,7 +1,8 @@
1const std = @import("std");
2const clap = @import("clap"); 1const clap = @import("clap");
2const std = @import("std");
3 3
4const debug = std.debug; 4const debug = std.debug;
5const io = std.io;
5 6
6pub fn main() !void { 7pub fn main() !void {
7 // First we specify what parameters our program can take. 8 // First we specify what parameters our program can take.
@@ -14,13 +15,12 @@ pub fn main() !void {
14 }; 15 };
15 16
16 // Initalize our diagnostics, which can be used for reporting useful errors. 17 // Initalize our diagnostics, which can be used for reporting useful errors.
17 // This is optional. You can also just pass `null` to `parser.next` if you 18 // This is optional. You can also pass `.{}` to `clap.parse` if you don't
18 // don't care about the extra information `Diagnostics` provides. 19 // care about the extra information `Diagnostics` provides.
19 var diag: clap.Diagnostic = undefined; 20 var diag = clap.Diagnostic{};
20 21 var args = clap.parse(clap.Help, &params, .{ .diagnostic = &diag }) catch |err| {
21 var args = clap.parse(clap.Help, &params, std.heap.page_allocator, &diag) catch |err| {
22 // Report useful error and exit 22 // Report useful error and exit
23 diag.report(std.io.getStdErr().writer(), err) catch {}; 23 diag.report(io.getStdErr().writer(), err) catch {};
24 return err; 24 return err;
25 }; 25 };
26 defer args.deinit(); 26 defer args.deinit();