From f8c72b5ca83b8c36da154b955f1dfdf7780efc38 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 4 Jan 2024 22:56:55 +0100 Subject: [PATCH] Run zig fmt --- args.zig | 42 ++++++++++++++++++++---------------------- demo.zig | 24 +++++++++++------------- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/args.zig b/args.zig index 282ac28..7f7903d 100644 --- a/args.zig +++ b/args.zig @@ -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"); } @@ -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) }); } } - - } } @@ -1038,7 +1036,7 @@ test "full help" { .option_docs = .{ .boolflag = "a boolean flag", .stringflag = "a string flag", - } + }, }; }; @@ -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); @@ -1075,7 +1073,7 @@ test "help with no usage summary" { .option_docs = .{ .boolflag = "a boolean flag", .stringflag = "a string flag", - } + }, }; }; @@ -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); diff --git a/demo.zig b/demo.zig index 1cfb4be..e2034d7 100644 --- a/demo.zig +++ b/demo.zig @@ -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;