rivertile: add -h/--help, improve man page

This commit is contained in:
Isaac Freund 2021-05-01 12:49:49 +02:00
parent 0c8e718d95
commit 4684f9fa47
No known key found for this signature in database
GPG key ID: 86DED400DDFD7A11
2 changed files with 46 additions and 6 deletions

View file

@ -10,28 +10,36 @@ rivertile - Tiled layout generator for river
# DESCRIPTION # DESCRIPTION
*rivertile* is a layout client for river. It provides a simple tiled layout *rivertile* is a layout client for *river*(1). It provides a simple tiled
split main/secondary stacks. layout with split main/secondary stacks. The initial state may be configured
with various options passed on startup. Some values may additionally be
modified while rivertile is running with the help of *riverctl*(1).
# OPTIONS # OPTIONS
*-view-padding* _pixels_ *-view-padding* _pixels_
Set the padding around views in pixels. Set the padding around views in pixels. (Default: 6)
*-outer-padding* _pixels_ *-outer-padding* _pixels_
Set the padding around the edge of the layout area in pixels. Set the padding around the edge of the layout area in pixels.
(Default: 6)
*-main-location* [*top*|*bottom*|*left*|*right*] *-main-location* [*top*|*bottom*|*left*|*right*]
Set the default location of the main area in the layout. Set the initial location of the main area in the layout.
(Default: *left*)
*-main-count* _count_ *-main-count* _count_
Set the default number of views in the main area of the layout. Set the initial number of views in the main area of the
layout. (Default: 1)
*-main-factor* _ratio_ *-main-factor* _ratio_
Set the default ratio of main area to total layout area. Set the initial ratio of main area to total layout area. (Default: 0.6)
# VALUES # VALUES
These values may be modified while rivertile is running with the help of
*riverctl*(1).
_main_location_ (string: top, bottom, left, or right) _main_location_ (string: top, bottom, left, or right)
The location of the main area in the layout. The location of the main area in the layout.
@ -41,6 +49,16 @@ _main_count_ (int)
_main_factor_ (fixed: [0.1, 0.9]) _main_factor_ (fixed: [0.1, 0.9])
The ratio of main area to total layout area. The ratio of main area to total layout area.
# EXAMPLES
Start *rivertile* with 4 pixels outer padding and 2 main views:
rivertile -outer-padding 4 -main-count 2
Set the main location of rivertile to top at runtime:
riverctl send-layout-value rivertile string main_location top
# AUTHORS # AUTHORS
Maintained by Isaac Freund <ifreund@ifreund.xyz> who is assisted by open Maintained by Isaac Freund <ifreund@ifreund.xyz> who is assisted by open

View file

@ -48,6 +48,22 @@ const river = wayland.client.river;
const Args = @import("args.zig").Args; const Args = @import("args.zig").Args;
const FlagDef = @import("args.zig").FlagDef; const FlagDef = @import("args.zig").FlagDef;
const usage =
\\Usage: rivertile [options]
\\
\\ -h, --help Print this help message 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)
\\ -main-location Set the initial location of the main area in the
\\ layout. (Default left)
\\ -main-count Set the initial number of views in the main area of the
\\ layout. (Default 1)
\\ -main-factor Set the initial ratio of main area to total layout
\\ area. (Default: 0.6)
\\
;
const Location = enum { const Location = enum {
top, top,
right, right,
@ -262,6 +278,8 @@ pub fn main() !void {
// https://github.com/ziglang/zig/issues/7807 // https://github.com/ziglang/zig/issues/7807
const argv: [][*:0]const u8 = std.os.argv; const argv: [][*:0]const u8 = std.os.argv;
const args = Args(0, &[_]FlagDef{ const args = Args(0, &[_]FlagDef{
.{ .name = "-h", .kind = .boolean },
.{ .name = "--help", .kind = .boolean },
.{ .name = "-view-padding", .kind = .arg }, .{ .name = "-view-padding", .kind = .arg },
.{ .name = "-outer-padding", .kind = .arg }, .{ .name = "-outer-padding", .kind = .arg },
.{ .name = "-main-location", .kind = .arg }, .{ .name = "-main-location", .kind = .arg },
@ -269,6 +287,10 @@ pub fn main() !void {
.{ .name = "-main-factor", .kind = .arg }, .{ .name = "-main-factor", .kind = .arg },
}).parse(argv[1..]); }).parse(argv[1..]);
if (args.boolFlag("-h") or args.boolFlag("--help")) {
std.io.getStdOut().writeAll(usage);
std.os.exit(0);
}
if (args.argFlag("-view-padding")) |raw| { if (args.argFlag("-view-padding")) |raw| {
view_padding = std.fmt.parseUnsigned(u32, mem.span(raw), 10) catch view_padding = std.fmt.parseUnsigned(u32, mem.span(raw), 10) catch
fatal("invalid value '{s}' provided to -view-padding", .{raw}); fatal("invalid value '{s}' provided to -view-padding", .{raw});