diff options
| author | Isaac Freund <mail@isaacfreund.com> | 2022-12-28 22:11:14 +0100 |
|---|---|---|
| committer | Isaac Freund <mail@isaacfreund.com> | 2022-12-28 22:11:14 +0100 |
| commit | e18d0d5e1cccb1aff321cc3a8a2a262685e918b9 (patch) | |
| tree | a2f6cc6d13fef1a14c75436af527e09efc6ab3ca /riverctl/main.zig | |
| parent | 2be9ac05d6ec1994a2dab1d5d2db979513bb94f2 (diff) | |
| download | river-e18d0d5e1cccb1aff321cc3a8a2a262685e918b9.tar.gz river-e18d0d5e1cccb1aff321cc3a8a2a262685e918b9.tar.xz | |
flags: automatically prepend '-'
This makes the usage a bit cleaner as the results of the parsing may be
accessed with e.g. ret.flags.version instead of ret.flags.@"-version".
Diffstat (limited to 'riverctl/main.zig')
| -rw-r--r-- | riverctl/main.zig | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/riverctl/main.zig b/riverctl/main.zig index 4cc6717..bffd20e 100644 --- a/riverctl/main.zig +++ b/riverctl/main.zig @@ -66,17 +66,17 @@ fn _main() !void { // This line is here because of https://github.com/ziglang/zig/issues/7807 const argv: [][*:0]const u8 = os.argv; const result = flags.parser([*:0]const u8, &.{ - .{ .name = "-h", .kind = .boolean }, - .{ .name = "-version", .kind = .boolean }, + .{ .name = "h", .kind = .boolean }, + .{ .name = "version", .kind = .boolean }, }).parse(argv[1..]) catch { try io.getStdErr().writeAll(usage); os.exit(1); }; - if (result.flags.@"-h") { + if (result.flags.h) { try io.getStdOut().writeAll(usage); os.exit(0); } - if (result.flags.@"-version") { + if (result.flags.version) { try io.getStdOut().writeAll(@import("build_options").version ++ "\n"); os.exit(0); } |
