diff options
Diffstat (limited to 'example/simple.zig')
| -rw-r--r-- | example/simple.zig | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/example/simple.zig b/example/simple.zig index 270e344..392dca3 100644 --- a/example/simple.zig +++ b/example/simple.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 | ||
| @@ -14,11 +14,10 @@ pub fn main() !void { | |||
| 14 | }; | 14 | }; |
| 15 | 15 | ||
| 16 | // Initalize our diagnostics, which can be used for reporting useful errors. | 16 | // 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 | 17 | // This is optional. You can also pass `.{}` to `clap.parse` if you don't |
| 18 | // don't care about the extra information `Diagnostics` provides. | 18 | // care about the extra information `Diagnostics` provides. |
| 19 | var diag: clap.Diagnostic = undefined; | 19 | var diag = clap.Diagnostic{}; |
| 20 | 20 | var args = clap.parse(clap.Help, ¶ms, .{ .diagnostic = &diag }) catch |err| { | |
| 21 | var args = clap.parse(clap.Help, ¶ms, std.heap.page_allocator, &diag) catch |err| { | ||
| 22 | // Report useful error and exit | 21 | // Report useful error and exit |
| 23 | diag.report(std.io.getStdErr().outStream(), err) catch {}; | 22 | diag.report(std.io.getStdErr().outStream(), err) catch {}; |
| 24 | return err; | 23 | return err; |