diff options
Diffstat (limited to 'example/comptime-clap-error.zig')
| -rw-r--r-- | example/comptime-clap-error.zig | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/example/comptime-clap-error.zig b/example/comptime-clap-error.zig new file mode 100644 index 0000000..93c1af2 --- /dev/null +++ b/example/comptime-clap-error.zig | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | const std = @import("std"); | ||
| 2 | const clap = @import("clap"); | ||
| 3 | |||
| 4 | pub fn main() !void { | ||
| 5 | const params = [_]clap.Param(void){clap.Param(void){ | ||
| 6 | .names = clap.Names{ .short = 'h', .long = "help" }, | ||
| 7 | }}; | ||
| 8 | |||
| 9 | var direct_allocator = std.heap.DirectAllocator.init(); | ||
| 10 | const allocator = &direct_allocator.allocator; | ||
| 11 | defer direct_allocator.deinit(); | ||
| 12 | |||
| 13 | var iter = clap.args.OsIterator.init(allocator); | ||
| 14 | defer iter.deinit(); | ||
| 15 | const exe = try iter.next(); | ||
| 16 | |||
| 17 | var args = try clap.ComptimeClap(void, params).parse(allocator, clap.args.OsIterator, &iter); | ||
| 18 | defer args.deinit(); | ||
| 19 | |||
| 20 | _ = args.flag("--helps"); | ||
| 21 | } | ||