diff options
Diffstat (limited to 'example/simple-error.zig')
| -rw-r--r-- | example/simple-error.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/example/simple-error.zig b/example/simple-error.zig new file mode 100644 index 0000000..fc72a03 --- /dev/null +++ b/example/simple-error.zig | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | const std = @import("std"); | ||
| 2 | const clap = @import("clap"); | ||
| 3 | |||
| 4 | pub fn main() !void { | ||
| 5 | // First we specify what parameters our program can take. | ||
| 6 | // We can use `parseParam` to parse a string to a `Param(Help)` | ||
| 7 | const params = comptime [_]clap.Param(clap.Help){ | ||
| 8 | clap.parseParam("-h, --help Display this help and exit.") catch unreachable, | ||
| 9 | }; | ||
| 10 | |||
| 11 | var args = try clap.parse(clap.Help, params, std.heap.direct_allocator); | ||
| 12 | defer args.deinit(); | ||
| 13 | |||
| 14 | _ = args.flag("--helps"); | ||
| 15 | } | ||