aboutsummaryrefslogtreecommitdiff
path: root/riverctl/main.zig
diff options
context:
space:
mode:
authorIsaac Freund <mail@isaacfreund.com>2022-12-28 19:47:09 +0100
committerIsaac Freund <mail@isaacfreund.com>2022-12-28 20:21:23 +0100
commit16cbe5f469594439035da63e1f40d3fffe66d9a9 (patch)
tree5d65c72cc656271f546ccaf94b21be01beb489ef /riverctl/main.zig
parentad1dbb1180a4fc5f2b5000a440b4a6f2683b8e8f (diff)
downloadriver-16cbe5f469594439035da63e1f40d3fffe66d9a9.tar.gz
river-16cbe5f469594439035da63e1f40d3fffe66d9a9.tar.xz
flags: rewrite to allow [:0]const u8 arguments
This also cleans up the code by using @Type(), eliminating the need for the argFlag() and boolFlag() functions. Allowing [:0]const u8 arguments makes this parser useful for river-control commands as well.
Diffstat (limited to 'riverctl/main.zig')
-rw-r--r--riverctl/main.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/riverctl/main.zig b/riverctl/main.zig
index 853b94e..4cc6717 100644
--- a/riverctl/main.zig
+++ b/riverctl/main.zig
@@ -65,18 +65,18 @@ pub fn main() !void {
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.parse(argv[1..], &[_]flags.Flag{
+ const result = flags.parser([*:0]const u8, &.{
.{ .name = "-h", .kind = .boolean },
.{ .name = "-version", .kind = .boolean },
- }) catch {
+ }).parse(argv[1..]) catch {
try io.getStdErr().writeAll(usage);
os.exit(1);
};
- if (result.boolFlag("-h")) {
+ if (result.flags.@"-h") {
try io.getStdOut().writeAll(usage);
os.exit(0);
}
- if (result.boolFlag("-version")) {
+ if (result.flags.@"-version") {
try io.getStdOut().writeAll(@import("build_options").version ++ "\n");
os.exit(0);
}