diff options
Diffstat (limited to 'example/simple.zig')
| -rw-r--r-- | example/simple.zig | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/example/simple.zig b/example/simple.zig index a7207c7..7f1bfc0 100644 --- a/example/simple.zig +++ b/example/simple.zig | |||
| @@ -1,9 +1,3 @@ | |||
| 1 | const clap = @import("clap"); | ||
| 2 | const std = @import("std"); | ||
| 3 | |||
| 4 | const debug = std.debug; | ||
| 5 | const io = std.io; | ||
| 6 | |||
| 7 | pub fn main() !void { | 1 | pub fn main() !void { |
| 8 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; | 2 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; |
| 9 | defer _ = gpa.deinit(); | 3 | defer _ = gpa.deinit(); |
| @@ -27,17 +21,20 @@ pub fn main() !void { | |||
| 27 | .allocator = gpa.allocator(), | 21 | .allocator = gpa.allocator(), |
| 28 | }) catch |err| { | 22 | }) catch |err| { |
| 29 | // Report useful error and exit | 23 | // Report useful error and exit |
| 30 | diag.report(io.getStdErr().writer(), err) catch {}; | 24 | diag.report(std.io.getStdErr().writer(), err) catch {}; |
| 31 | return err; | 25 | return err; |
| 32 | }; | 26 | }; |
| 33 | defer res.deinit(); | 27 | defer res.deinit(); |
| 34 | 28 | ||
| 35 | if (res.args.help != 0) | 29 | if (res.args.help != 0) |
| 36 | debug.print("--help\n", .{}); | 30 | std.debug.print("--help\n", .{}); |
| 37 | if (res.args.number) |n| | 31 | if (res.args.number) |n| |
| 38 | debug.print("--number = {}\n", .{n}); | 32 | std.debug.print("--number = {}\n", .{n}); |
| 39 | for (res.args.string) |s| | 33 | for (res.args.string) |s| |
| 40 | debug.print("--string = {s}\n", .{s}); | 34 | std.debug.print("--string = {s}\n", .{s}); |
| 41 | for (res.positionals) |pos| | 35 | for (res.positionals) |pos| |
| 42 | debug.print("{s}\n", .{pos}); | 36 | std.debug.print("{s}\n", .{pos}); |
| 43 | } | 37 | } |
| 38 | |||
| 39 | const clap = @import("clap"); | ||
| 40 | const std = @import("std"); | ||