Minor improvements
Let's not mark toggles as required... they shouldn't be.
This commit is contained in:
parent
1617926615
commit
5eae72b4c1
1 changed files with 8 additions and 6 deletions
|
|
@ -151,13 +151,15 @@ pub fn printHelp(comptime T: type, comptime name: []const u8, writer: std.io.Any
|
||||||
try writer.print(")", .{});
|
try writer.print(")", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
try writer.print(": {s}", .{valueType});
|
if (flag.takesValue) {
|
||||||
|
try writer.print(": {s}", .{valueType});
|
||||||
|
|
||||||
if (flag.typeHint) |typeHint| {
|
if (flag.typeHint) |typeHint| {
|
||||||
try writer.print(" ({s})", .{typeHint});
|
try writer.print(" ({s})", .{typeHint});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isOptional) {
|
if (!isOptional and !flag.toggle) {
|
||||||
try writer.print(" <required>", .{});
|
try writer.print(" <required>", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -199,7 +201,7 @@ test "basic help" {
|
||||||
.Flag = .{
|
.Flag = .{
|
||||||
.name = "verbose",
|
.name = "verbose",
|
||||||
.short = "v",
|
.short = "v",
|
||||||
.takesValue = false,
|
|
||||||
.toggle = true,
|
.toggle = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -221,7 +223,7 @@ test "basic help" {
|
||||||
\\Usage: demo [flags] <positional> [...]
|
\\Usage: demo [flags] <positional> [...]
|
||||||
\\Legend: <required> [optional]
|
\\Legend: <required> [optional]
|
||||||
\\
|
\\
|
||||||
\\* --verbose (-v): bool <required>
|
\\* --verbose (-v)
|
||||||
\\* <positional>: string
|
\\* <positional>: string
|
||||||
\\
|
\\
|
||||||
, buf.items);
|
, buf.items);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue