diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2021-07-24 19:31:04 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2021-07-24 19:31:04 +0200 |
| commit | 23088b800c9e4166396996de82fb1b13c8671127 (patch) | |
| tree | b5b497bf322f1eb6fe5aa86f9a529786e934ff6b /rivertile/main.zig | |
| parent | a5a505ecbaecacbc79c515daf55ea55ab8e475f0 (diff) | |
| download | river-23088b800c9e4166396996de82fb1b13c8671127.tar.gz river-23088b800c9e4166396996de82fb1b13c8671127.tar.xz | |
common: standardize on -help option
Also:
- Check for -help option *before* unknown options
- Use common flags parsing code for riverctl
- Add usage text to riverctl
Diffstat (limited to 'rivertile/main.zig')
| -rw-r--r-- | rivertile/main.zig | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/rivertile/main.zig b/rivertile/main.zig index 59a0f6e..2116341 100644 --- a/rivertile/main.zig +++ b/rivertile/main.zig @@ -51,7 +51,7 @@ const flags = @import("flags"); const usage = \\usage: rivertile [options] \\ - \\ -h, --help Print this help message and exit. + \\ -help Print this help message and exit. \\ -version Print the version number and exit. \\ -view-padding Set the padding around views in pixels. (Default 6) \\ -outer-padding Set the padding around the edge of the layout area in @@ -314,8 +314,7 @@ pub fn main() !void { // https://github.com/ziglang/zig/issues/7807 const argv: [][*:0]const u8 = os.argv; const result = flags.parse(argv[1..], &[_]flags.Flag{ - .{ .name = "-h", .kind = .boolean }, - .{ .name = "--help", .kind = .boolean }, + .{ .name = "-help", .kind = .boolean }, .{ .name = "-version", .kind = .boolean }, .{ .name = "-view-padding", .kind = .arg }, .{ .name = "-outer-padding", .kind = .arg }, @@ -326,12 +325,12 @@ pub fn main() !void { try std.io.getStdErr().writeAll(usage); os.exit(1); }; - if (result.args.len != 0) fatalPrintUsage("unknown option '{s}'", .{result.args[0]}); - - if (result.boolFlag("-h") or result.boolFlag("--help")) { + if (result.boolFlag("-help")) { try std.io.getStdOut().writeAll(usage); os.exit(0); } + if (result.args.len != 0) fatalPrintUsage("unknown option '{s}'", .{result.args[0]}); + if (result.boolFlag("-version")) { try std.io.getStdOut().writeAll(@import("build_options").version); os.exit(0); |
