Add -version flag to river, riverctl and rivertile

This commit is contained in:
novakane
2021-07-24 11:31:17 +02:00
committed by Isaac Freund
parent 9c633a7888
commit 32d35cdf91
4 changed files with 41 additions and 1 deletions

View File

@ -52,6 +52,7 @@ const usage =
\\Usage: rivertile [options]
\\
\\ -h, --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
\\ pixels. (Default 6)
@ -315,6 +316,7 @@ pub fn main() !void {
const args = Args(0, &[_]FlagDef{
.{ .name = "-h", .kind = .boolean },
.{ .name = "--help", .kind = .boolean },
.{ .name = "-version", .kind = .boolean },
.{ .name = "-view-padding", .kind = .arg },
.{ .name = "-outer-padding", .kind = .arg },
.{ .name = "-main-location", .kind = .arg },
@ -326,6 +328,10 @@ pub fn main() !void {
try std.io.getStdOut().writeAll(usage);
std.os.exit(0);
}
if (args.boolFlag("-version")) {
try std.io.getStdOut().writeAll(@import("build_options").version);
std.os.exit(0);
}
if (args.argFlag("-view-padding")) |raw| {
view_padding = std.fmt.parseUnsigned(u32, mem.span(raw), 10) catch
fatal("invalid value '{s}' provided to -view-padding", .{raw});