diff options
| author | 2024-10-22 17:46:47 +0200 | |
|---|---|---|
| committer | 2024-10-22 17:48:34 +0200 | |
| commit | e73b56aa4bcb7e53144ef96ee978f2a19b32669d (patch) | |
| tree | 0ab5e3d426e25d2ad9d2e0cd0015fc010d9ea182 /example/simple-ex.zig | |
| parent | feat: Add `terminating_positional` to `clap.ParseOptions` (diff) | |
| download | zig-clap-e73b56aa4bcb7e53144ef96ee978f2a19b32669d.tar.gz zig-clap-e73b56aa4bcb7e53144ef96ee978f2a19b32669d.tar.xz zig-clap-e73b56aa4bcb7e53144ef96ee978f2a19b32669d.zip | |
refactor: Always access using full namespace
This is my new preferred style of programming Zig :)
Diffstat (limited to '')
| -rw-r--r-- | example/simple-ex.zig | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/example/simple-ex.zig b/example/simple-ex.zig index 2943f4e..4ca9791 100644 --- a/example/simple-ex.zig +++ b/example/simple-ex.zig | |||
| @@ -1,10 +1,3 @@ | |||
| 1 | const clap = @import("clap"); | ||
| 2 | const std = @import("std"); | ||
| 3 | |||
| 4 | const debug = std.debug; | ||
| 5 | const io = std.io; | ||
| 6 | const process = std.process; | ||
| 7 | |||
| 8 | pub fn main() !void { | 1 | pub fn main() !void { |
| 9 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; | 2 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; |
| 10 | defer _ = gpa.deinit(); | 3 | defer _ = gpa.deinit(); |
| @@ -38,19 +31,22 @@ pub fn main() !void { | |||
| 38 | // allowed. | 31 | // allowed. |
| 39 | .assignment_separators = "=:", | 32 | .assignment_separators = "=:", |
| 40 | }) catch |err| { | 33 | }) catch |err| { |
| 41 | diag.report(io.getStdErr().writer(), err) catch {}; | 34 | diag.report(std.io.getStdErr().writer(), err) catch {}; |
| 42 | return err; | 35 | return err; |
| 43 | }; | 36 | }; |
| 44 | defer res.deinit(); | 37 | defer res.deinit(); |
| 45 | 38 | ||
| 46 | if (res.args.help != 0) | 39 | if (res.args.help != 0) |
| 47 | debug.print("--help\n", .{}); | 40 | std.debug.print("--help\n", .{}); |
| 48 | if (res.args.number) |n| | 41 | if (res.args.number) |n| |
| 49 | debug.print("--number = {}\n", .{n}); | 42 | std.debug.print("--number = {}\n", .{n}); |
| 50 | if (res.args.answer) |a| | 43 | if (res.args.answer) |a| |
| 51 | debug.print("--answer = {s}\n", .{@tagName(a)}); | 44 | std.debug.print("--answer = {s}\n", .{@tagName(a)}); |
| 52 | for (res.args.string) |s| | 45 | for (res.args.string) |s| |
| 53 | debug.print("--string = {s}\n", .{s}); | 46 | std.debug.print("--string = {s}\n", .{s}); |
| 54 | for (res.positionals) |pos| | 47 | for (res.positionals) |pos| |
| 55 | debug.print("{s}\n", .{pos}); | 48 | std.debug.print("{s}\n", .{pos}); |
| 56 | } | 49 | } |
| 50 | |||
| 51 | const clap = @import("clap"); | ||
| 52 | const std = @import("std"); | ||