Skip to content

Commit

Permalink
feat(HelpMessageWriter): Display option values at the same line as na…
Browse files Browse the repository at this point in the history
…me if description is not set

Signed-off-by: prajwalch <prajwal.chapagain58@gmail.com>
  • Loading branch information
prajwalch committed Sep 11, 2024
1 parent edcd2d2 commit b22ac37
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/HelpMessageWriter.zig
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,18 @@ fn writeOption(self: *HelpMessageWriter, option: *const Arg) !void {
// Description.
if (option.description) |description| {
try line.description.writeAll(description);
try writer.print("{}", .{line});
}

try writer.print("{}", .{line});

// If the acceptable values are set for the option, print them at the new
// line but just below the description.
if (option.valid_values) |valid_values| {
// If the description is not set then print the values at the same line.
if (option.description == null) {
try line.description.print("values: {s}", .{valid_values});
return writer.print("{}", .{line});
}

// If the description is set then print the values at the new line
// but just below the description.
var new_line = Line.init();
try new_line.description.addPadding(2);
try new_line.description.print("values: {s}", .{valid_values});
Expand Down

0 comments on commit b22ac37

Please sign in to comment.