Skip to content

Commit

Permalink
Run zig fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
linusg committed Jan 5, 2024
1 parent ba3bf13 commit f8c72b5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 35 deletions.
42 changes: 20 additions & 22 deletions args.zig
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ test "index of raw indicator --" {
try std.testing.expectEqual(args.positionals.len, 5);
}

fn reserved_argument(arg: [] const u8) bool {
fn reserved_argument(arg: []const u8) bool {
return std.mem.eql(u8, arg, "shorthands") or std.mem.eql(u8, arg, "meta");
}

Expand Down Expand Up @@ -1014,11 +1014,9 @@ pub fn printHelp(comptime Generic: type, name: []const u8, writer: anytype) !voi
try writer.print(" ", .{});
}
const fmtString = std.fmt.comptimePrint("--{{s: <{}}} {{s}}\n", .{maxOptionLength});
try writer.print(fmtString, .{field.name, @field(Generic.meta.option_docs, field.name)});
try writer.print(fmtString, .{ field.name, @field(Generic.meta.option_docs, field.name) });
}
}


}
}

Expand All @@ -1038,7 +1036,7 @@ test "full help" {
.option_docs = .{
.boolflag = "a boolean flag",
.stringflag = "a string flag",
}
},
};
};

Expand All @@ -1048,14 +1046,14 @@ test "full help" {
try printHelp(Options, "test", test_buffer.writer());

const expected =
\\Usage: test [--boolflag] [--stringflag]
\\
\\testing tool
\\
\\Options:
\\ -b, --boolflag a boolean flag
\\ --stringflag a string flag
\\
\\Usage: test [--boolflag] [--stringflag]
\\
\\testing tool
\\
\\Options:
\\ -b, --boolflag a boolean flag
\\ --stringflag a string flag
\\
;

try std.testing.expectEqualStrings(expected, test_buffer.items);
Expand All @@ -1075,7 +1073,7 @@ test "help with no usage summary" {
.option_docs = .{
.boolflag = "a boolean flag",
.stringflag = "a string flag",
}
},
};
};

Expand All @@ -1085,14 +1083,14 @@ test "help with no usage summary" {
try printHelp(Options, "test", test_buffer.writer());

const expected =
\\Usage: test
\\
\\testing tool
\\
\\Options:
\\ -b, --boolflag a boolean flag
\\ --stringflag a string flag
\\
\\Usage: test
\\
\\testing tool
\\
\\Options:
\\ -b, --boolflag a boolean flag
\\ --stringflag a string flag
\\
;

try std.testing.expectEqualStrings(expected, test_buffer.items);
Expand Down
24 changes: 11 additions & 13 deletions demo.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@ pub fn main() !u8 {
.o = "output",
};

pub const meta = .{
.option_docs = .{
.output= "output help",
.@"with-offset" = "with-offset help",
.@"with-hexdump" = "with-hexdump help",
.@"intermix-source" = "intermix-source",
.numberOfBytes = "numberOfBytes help",
.signed_number = "signed_number help",
.unsigned_number = "unsigned_number help",
.mode = "mode help",
.help = "help help",
}
};
pub const meta = .{ .option_docs = .{
.output = "output help",
.@"with-offset" = "with-offset help",
.@"with-hexdump" = "with-hexdump help",
.@"intermix-source" = "intermix-source",
.numberOfBytes = "numberOfBytes help",
.signed_number = "signed_number help",
.unsigned_number = "unsigned_number help",
.mode = "mode help",
.help = "help help",
} };
};

const options = argsParser.parseForCurrentProcess(Options, argsAllocator, .print) catch return 1;
Expand Down

0 comments on commit f8c72b5

Please sign in to comment.