Skip to content

Commit

Permalink
common: use -h instead of -help
Browse files Browse the repository at this point in the history
This doesn't really matter that much as unrecognized options will still
trigger a help message to be printed, but -h is much more standard so
lets make the predictable choice here while sticking to only single '-'
flags.
  • Loading branch information
ifreund committed Oct 31, 2021
1 parent 4cee1fb commit f2cf4b9
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion doc/river.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ utility may be used to communicate with river over these protocols.

# OPTIONS

*-help*
*-h*
Print a help message and exit.

*-version*
Expand Down
2 changes: 1 addition & 1 deletion doc/riverctl.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ over the Wayland protocol.

# OPTIONS

*-help*
*-h*
Print a help message and exit.

*-version*
Expand Down
2 changes: 1 addition & 1 deletion doc/rivertile.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ modified while rivertile is running with the help of *riverctl*(1).

# OPTIONS

*-help*
*-h*
Print a help message and exit.

*-version*
Expand Down
6 changes: 3 additions & 3 deletions river/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Server = @import("Server.zig");
const usage: []const u8 =
\\usage: river [options]
\\
\\ -help Print this help message and exit.
\\ -h Print this help message and exit.
\\ -version Print the version number and exit.
\\ -c <command> Run `sh -c <command>` on startup.
\\ -log-level <level> Set the log level to error, warning, info, or debug.
Expand All @@ -44,15 +44,15 @@ pub fn main() anyerror!void {
// This line is here because of https://github.com/ziglang/zig/issues/7807
const argv: [][*:0]const u8 = os.argv;
const result = flags.parse(argv[1..], &[_]flags.Flag{
.{ .name = "-help", .kind = .boolean },
.{ .name = "-h", .kind = .boolean },
.{ .name = "-version", .kind = .boolean },
.{ .name = "-c", .kind = .arg },
.{ .name = "-log-level", .kind = .arg },
}) catch {
try io.getStdErr().writeAll(usage);
os.exit(1);
};
if (result.boolFlag("-help")) {
if (result.boolFlag("-h")) {
try io.getStdOut().writeAll(usage);
os.exit(0);
}
Expand Down
6 changes: 3 additions & 3 deletions riverctl/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const flags = @import("flags");
const usage =
\\usage: riverctl [options] <command>
\\
\\ -help Print this help message and exit.
\\ -h Print this help message and exit.
\\ -version Print the version number and exit.
\\
\\Complete documentation of the recognized commands may be found in
Expand Down Expand Up @@ -67,13 +67,13 @@ fn _main() !void {
// This line is here because of https://github.com/ziglang/zig/issues/7807
const argv: [][*:0]const u8 = os.argv;
const result = flags.parse(argv[1..], &[_]flags.Flag{
.{ .name = "-help", .kind = .boolean },
.{ .name = "-h", .kind = .boolean },
.{ .name = "-version", .kind = .boolean },
}) catch {
try io.getStdErr().writeAll(usage);
os.exit(1);
};
if (result.boolFlag("-help")) {
if (result.boolFlag("-h")) {
try io.getStdOut().writeAll(usage);
os.exit(0);
}
Expand Down
6 changes: 3 additions & 3 deletions rivertile/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const flags = @import("flags");
const usage =
\\usage: rivertile [options]
\\
\\ -help Print this help message and exit.
\\ -h 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
Expand Down Expand Up @@ -314,7 +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 = "-help", .kind = .boolean },
.{ .name = "-h", .kind = .boolean },
.{ .name = "-version", .kind = .boolean },
.{ .name = "-view-padding", .kind = .arg },
.{ .name = "-outer-padding", .kind = .arg },
Expand All @@ -325,7 +325,7 @@ pub fn main() !void {
try std.io.getStdErr().writeAll(usage);
os.exit(1);
};
if (result.boolFlag("-help")) {
if (result.boolFlag("-h")) {
try std.io.getStdOut().writeAll(usage);
os.exit(0);
}
Expand Down

0 comments on commit f2cf4b9

Please sign in to comment.