diff options
| -rw-r--r-- | build.zig | 3 | ||||
| -rw-r--r-- | example/comptime-clap.zig | 4 | ||||
| -rw-r--r-- | example/simple.zig | 4 | ||||
| -rw-r--r-- | example/streaming-clap.zig | 4 |
4 files changed, 9 insertions, 6 deletions
| @@ -9,7 +9,9 @@ pub fn build(b: *Builder) void { | |||
| 9 | 9 | ||
| 10 | const fmt_step = b.addFmt(&[_][]const u8{ | 10 | const fmt_step = b.addFmt(&[_][]const u8{ |
| 11 | "build.zig", | 11 | "build.zig", |
| 12 | "clap.zig", | ||
| 12 | "clap", | 13 | "clap", |
| 14 | "example", | ||
| 13 | }); | 15 | }); |
| 14 | 16 | ||
| 15 | const test_all_step = b.step("test", "Run all tests in all modes."); | 17 | const test_all_step = b.step("test", "Run all tests in all modes."); |
| @@ -51,6 +53,7 @@ pub fn build(b: *Builder) void { | |||
| 51 | all_step.dependOn(example_step); | 53 | all_step.dependOn(example_step); |
| 52 | all_step.dependOn(readme_step); | 54 | all_step.dependOn(readme_step); |
| 53 | 55 | ||
| 56 | b.default_step.dependOn(&fmt_step.step); | ||
| 54 | b.default_step.dependOn(all_step); | 57 | b.default_step.dependOn(all_step); |
| 55 | } | 58 | } |
| 56 | 59 | ||
diff --git a/example/comptime-clap.zig b/example/comptime-clap.zig index f5c0221..d5c84fe 100644 --- a/example/comptime-clap.zig +++ b/example/comptime-clap.zig | |||
| @@ -28,7 +28,7 @@ pub fn main() !void { | |||
| 28 | if (args.flag("--help")) | 28 | if (args.flag("--help")) |
| 29 | debug.warn("--help\n", .{}); | 29 | debug.warn("--help\n", .{}); |
| 30 | if (args.option("--number")) |n| | 30 | if (args.option("--number")) |n| |
| 31 | debug.warn("--number = {}\n", .{ n }); | 31 | debug.warn("--number = {}\n", .{n}); |
| 32 | for (args.positionals()) |pos| | 32 | for (args.positionals()) |pos| |
| 33 | debug.warn("{}\n", .{ pos }); | 33 | debug.warn("{}\n", .{pos}); |
| 34 | } | 34 | } |
diff --git a/example/simple.zig b/example/simple.zig index d546223..3510317 100644 --- a/example/simple.zig +++ b/example/simple.zig | |||
| @@ -20,7 +20,7 @@ pub fn main() !void { | |||
| 20 | if (args.flag("--help")) | 20 | if (args.flag("--help")) |
| 21 | debug.warn("--help\n", .{}); | 21 | debug.warn("--help\n", .{}); |
| 22 | if (args.option("--number")) |n| | 22 | if (args.option("--number")) |n| |
| 23 | debug.warn("--number = {}\n", .{ n }); | 23 | debug.warn("--number = {}\n", .{n}); |
| 24 | for (args.positionals()) |pos| | 24 | for (args.positionals()) |pos| |
| 25 | debug.warn("{}\n", .{ pos }); | 25 | debug.warn("{}\n", .{pos}); |
| 26 | } | 26 | } |
diff --git a/example/streaming-clap.zig b/example/streaming-clap.zig index 4cc43d1..faf388a 100644 --- a/example/streaming-clap.zig +++ b/example/streaming-clap.zig | |||
| @@ -39,12 +39,12 @@ pub fn main() !void { | |||
| 39 | // arg.param will point to the parameter which matched the argument. | 39 | // arg.param will point to the parameter which matched the argument. |
| 40 | switch (arg.param.id) { | 40 | switch (arg.param.id) { |
| 41 | 'h' => debug.warn("Help!\n", .{}), | 41 | 'h' => debug.warn("Help!\n", .{}), |
| 42 | 'n' => debug.warn("--number = {}\n", .{ arg.value.? }), | 42 | 'n' => debug.warn("--number = {}\n", .{arg.value.?}), |
| 43 | 43 | ||
| 44 | // arg.value == null, if arg.param.takes_value == false. | 44 | // arg.value == null, if arg.param.takes_value == false. |
| 45 | // Otherwise, arg.value is the value passed with the argument, such as "-a=10" | 45 | // Otherwise, arg.value is the value passed with the argument, such as "-a=10" |
| 46 | // or "-a 10". | 46 | // or "-a 10". |
| 47 | 'f' => debug.warn("{}\n", .{ arg.value.? }), | 47 | 'f' => debug.warn("{}\n", .{arg.value.?}), |
| 48 | else => unreachable, | 48 | else => unreachable, |
| 49 | } | 49 | } |
| 50 | } | 50 | } |