Minor improvements

Let's not mark toggles as required... they shouldn't be.
This commit is contained in:
Lyssieth 2024-11-28 18:12:06 +02:00
parent 1617926615
commit 5eae72b4c1
Signed by untrusted user who does not match committer: lyssieth
GPG key ID: 200268854934CFAB

View file

@ -151,13 +151,15 @@ pub fn printHelp(comptime T: type, comptime name: []const u8, writer: std.io.Any
try writer.print(")", .{});
}
if (flag.takesValue) {
try writer.print(": {s}", .{valueType});
if (flag.typeHint) |typeHint| {
try writer.print(" ({s})", .{typeHint});
}
}
if (!isOptional) {
if (!isOptional and !flag.toggle) {
try writer.print(" <required>", .{});
}
@ -199,7 +201,7 @@ test "basic help" {
.Flag = .{
.name = "verbose",
.short = "v",
.takesValue = false,
.toggle = true,
},
},
@ -221,7 +223,7 @@ test "basic help" {
\\Usage: demo [flags] <positional> [...]
\\Legend: <required> [optional]
\\
\\* --verbose (-v): bool <required>
\\* --verbose (-v)
\\* <positional>: string
\\
, buf.items);