aboutsummaryrefslogtreecommitdiff
path: root/rivertile/main.zig
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2021-07-24 19:31:04 +0200
committerIsaac Freund <ifreund@ifreund.xyz>2021-07-24 19:31:04 +0200
commit23088b800c9e4166396996de82fb1b13c8671127 (patch)
treeb5b497bf322f1eb6fe5aa86f9a529786e934ff6b /rivertile/main.zig
parenta5a505ecbaecacbc79c515daf55ea55ab8e475f0 (diff)
downloadriver-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.zig11
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);