diff options
Diffstat (limited to '')
| -rw-r--r-- | example/simple-ex.zig | 14 |
1 files changed, 8 insertions, 6 deletions
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 @@ | |||
| 1 | const std = @import("std"); | ||
| 2 | const clap = @import("clap"); | 1 | const clap = @import("clap"); |
| 2 | const std = @import("std"); | ||
| 3 | 3 | ||
| 4 | const debug = std.debug; | 4 | const debug = std.debug; |
| 5 | 5 | ||
| @@ -21,11 +21,13 @@ pub fn main() !void { | |||
| 21 | defer iter.deinit(); | 21 | defer iter.deinit(); |
| 22 | 22 | ||
| 23 | // Initalize our diagnostics, which can be used for reporting useful errors. | 23 | // Initalize our diagnostics, which can be used for reporting useful errors. |
| 24 | // This is optional. You can also just pass `null` to `parser.next` if you | 24 | // This is optional. You can also pass `.{}` to `clap.parse` if you don't |
| 25 | // don't care about the extra information `Diagnostics` provides. | 25 | // care about the extra information `Diagnostics` provides. |
| 26 | var diag: clap.Diagnostic = undefined; | 26 | var diag = clap.Diagnostic{}; |
| 27 | 27 | var args = clap.parseEx(clap.Help, ¶ms, &iter, .{ | |
| 28 | var args = clap.parseEx(clap.Help, ¶ms, allocator, &iter, &diag) catch |err| { | 28 | .allocator = allocator, |
| 29 | .diagnostic = &diag, | ||
| 30 | }) catch |err| { | ||
| 29 | // Report useful error and exit | 31 | // Report useful error and exit |
| 30 | diag.report(std.io.getStdErr().outStream(), err) catch {}; | 32 | diag.report(std.io.getStdErr().outStream(), err) catch {}; |
| 31 | return err; | 33 | return err; |