Run zig fmt on build

This commit is contained in:
Jimmi Holst Christensen 2020-04-18 16:46:45 +02:00
parent 0b1dd505dd
commit 11753e80d6
4 changed files with 9 additions and 6 deletions

View File

@ -9,7 +9,9 @@ pub fn build(b: *Builder) void {
const fmt_step = b.addFmt(&[_][]const u8{
"build.zig",
"clap.zig",
"clap",
"example",
});
const test_all_step = b.step("test", "Run all tests in all modes.");
@ -51,6 +53,7 @@ pub fn build(b: *Builder) void {
all_step.dependOn(example_step);
all_step.dependOn(readme_step);
b.default_step.dependOn(&fmt_step.step);
b.default_step.dependOn(all_step);
}

View File

@ -28,7 +28,7 @@ pub fn main() !void {
if (args.flag("--help"))
debug.warn("--help\n", .{});
if (args.option("--number")) |n|
debug.warn("--number = {}\n", .{ n });
debug.warn("--number = {}\n", .{n});
for (args.positionals()) |pos|
debug.warn("{}\n", .{ pos });
debug.warn("{}\n", .{pos});
}

View File

@ -20,7 +20,7 @@ pub fn main() !void {
if (args.flag("--help"))
debug.warn("--help\n", .{});
if (args.option("--number")) |n|
debug.warn("--number = {}\n", .{ n });
debug.warn("--number = {}\n", .{n});
for (args.positionals()) |pos|
debug.warn("{}\n", .{ pos });
debug.warn("{}\n", .{pos});
}

View File

@ -39,12 +39,12 @@ pub fn main() !void {
// arg.param will point to the parameter which matched the argument.
switch (arg.param.id) {
'h' => debug.warn("Help!\n", .{}),
'n' => debug.warn("--number = {}\n", .{ arg.value.? }),
'n' => debug.warn("--number = {}\n", .{arg.value.?}),
// arg.value == null, if arg.param.takes_value == false.
// Otherwise, arg.value is the value passed with the argument, such as "-a=10"
// or "-a 10".
'f' => debug.warn("{}\n", .{ arg.value.? }),
'f' => debug.warn("{}\n", .{arg.value.?}),
else => unreachable,
}
}