diff options
Diffstat (limited to 'example/streaming-clap.zig')
| -rw-r--r-- | example/streaming-clap.zig | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/example/streaming-clap.zig b/example/streaming-clap.zig index 0361d46..4cc43d1 100644 --- a/example/streaming-clap.zig +++ b/example/streaming-clap.zig | |||
| @@ -4,7 +4,7 @@ const clap = @import("clap"); | |||
| 4 | const debug = std.debug; | 4 | const debug = std.debug; |
| 5 | 5 | ||
| 6 | pub fn main() !void { | 6 | pub fn main() !void { |
| 7 | const allocator = std.heap.direct_allocator; | 7 | const allocator = std.heap.page_allocator; |
| 8 | 8 | ||
| 9 | // First we specify what parameters our program can take. | 9 | // First we specify what parameters our program can take. |
| 10 | const params = [_]clap.Param(u8){ | 10 | const params = [_]clap.Param(u8){ |
| @@ -30,7 +30,7 @@ pub fn main() !void { | |||
| 30 | 30 | ||
| 31 | // Initialize our streaming parser. | 31 | // Initialize our streaming parser. |
| 32 | var parser = clap.StreamingClap(u8, clap.args.OsIterator){ | 32 | var parser = clap.StreamingClap(u8, clap.args.OsIterator){ |
| 33 | .params = params, | 33 | .params = ¶ms, |
| 34 | .iter = &iter, | 34 | .iter = &iter, |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| @@ -38,13 +38,13 @@ pub fn main() !void { | |||
| 38 | while (try parser.next()) |arg| { | 38 | while (try parser.next()) |arg| { |
| 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 | } |