diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2020-06-16 17:06:24 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2020-06-16 17:06:24 +0200 |
| commit | 751760287c15e511ed4a9cd4f977e27673f07cb6 (patch) | |
| tree | 282dcf53828fb313b20dd0cee66a872af16551c6 | |
| parent | e2c034b76a4f639c3962f1dd7b208c33e29628e4 (diff) | |
| download | river-751760287c15e511ed4a9cd4f977e27673f07cb6.tar.gz river-751760287c15e511ed4a9cd4f977e27673f07cb6.tar.xz | |
docs: add rivertile man page
| -rw-r--r-- | build.zig | 1 | ||||
| -rw-r--r-- | doc/rivertile.1.scd | 38 | ||||
| -rw-r--r-- | rivertile/main.zig | 26 |
3 files changed, 59 insertions, 6 deletions
@@ -217,6 +217,7 @@ const ScdocStep = struct { const scd_paths = [_][]const u8{ "doc/river.1.scd", "doc/riverctl.1.scd", + "doc/rivertile.1.scd", "doc/river-layouts.1.scd", }; diff --git a/doc/rivertile.1.scd b/doc/rivertile.1.scd new file mode 100644 index 0000000..3a7fd49 --- /dev/null +++ b/doc/rivertile.1.scd @@ -0,0 +1,38 @@ +RIVERTILE(1) "github.com/ifreund/river" "General Commands Manual" + +# NAME + +rivertile - tiled layout generator for river + +# SYNOPSIS + +*rivertile* *left*|*right*|*top*|*bottom* [args passed by river] + +# DESCRIPTION + +*rivertile* is a layout generator for river. It produces tiled layouts with +split master/secondary stacks in four configurable orientations. + +# OPTIONS + +*left* + Place the master stack on the left side of the output. + +*right* + Place the master stack on the right side of the output. + +*top* + Place the master stack at the top of the output. + +*bottom* + Place the master stack at the bottom of the output. + +# EXAMPLE + +Set river's layout to *rivertile*'s *left* layout using riverctl + + riverctl layout rivertile left + +# SEE ALSO + +*river-layouts*(7), *river*(1), *riverctl*(1) diff --git a/rivertile/main.zig b/rivertile/main.zig index 8171dcc..911754e 100644 --- a/rivertile/main.zig +++ b/rivertile/main.zig @@ -45,13 +45,17 @@ const Orientation = enum { /// | | | /// +-----------------------+------------+ pub fn main() !void { + const args = std.os.argv; + if (args.len != 7) printUsageAndExit(); + // first arg must be left, right, top, or bottom - const master_location = std.meta.stringToEnum(Orientation, std.mem.spanZ(std.os.argv[1])).?; + const master_location = std.meta.stringToEnum(Orientation, std.mem.spanZ(args[1])) orelse + printUsageAndExit(); // the other 5 are passed by river and described in river-layouts(7) - const num_views = try std.fmt.parseInt(u32, std.mem.spanZ(std.os.argv[2]), 10); - const master_count = try std.fmt.parseInt(u32, std.mem.spanZ(std.os.argv[3]), 10); - const master_factor = try std.fmt.parseFloat(f64, std.mem.spanZ(std.os.argv[4])); + const num_views = try std.fmt.parseInt(u32, std.mem.spanZ(args[2]), 10); + const master_count = try std.fmt.parseInt(u32, std.mem.spanZ(args[3]), 10); + const master_factor = try std.fmt.parseFloat(f64, std.mem.spanZ(args[4])); const width_arg: u32 = switch (master_location) { .left, .right => 5, @@ -59,8 +63,8 @@ pub fn main() !void { }; const height_arg: u32 = if (width_arg == 5) 6 else 5; - const output_width = try std.fmt.parseInt(u32, std.mem.spanZ(std.os.argv[width_arg]), 10); - const output_height = try std.fmt.parseInt(u32, std.mem.spanZ(std.os.argv[height_arg]), 10); + const output_width = try std.fmt.parseInt(u32, std.mem.spanZ(args[width_arg]), 10); + const output_height = try std.fmt.parseInt(u32, std.mem.spanZ(args[height_arg]), 10); const secondary_count = num_views - master_count; @@ -126,3 +130,13 @@ pub fn main() !void { try stdout_buf.flush(); } + +fn printUsageAndExit() noreturn { + const usage: []const u8 = + \\Usage: rivertile left|right|top|bottom [args passed by river] + \\ + ; + + std.debug.warn(usage, .{}); + std.os.exit(1); +} |
