diff options
Diffstat (limited to 'example/simple.zig')
| -rw-r--r-- | example/simple.zig | 14 |
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 @@ | |||
| 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 | const io = std.io; | ||
| 5 | 6 | ||
| 6 | pub fn main() !void { | 7 | pub 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, ¶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 | 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(); |