summaryrefslogtreecommitdiff
path: root/example/simple-error.zig
diff options
context:
space:
mode:
authorGravatar Jimmi Holst Christensen2019-11-27 23:13:31 +0900
committerGravatar Jimmi Holst Christensen2019-11-27 23:13:31 +0900
commita305e818bd986c599fff17141617bc4f890276cf (patch)
treeff0a5c133c271d83de3e71ebc023ffc08bb1e3c9 /example/simple-error.zig
parentBreaking: OsIterator will now get the exe on init (diff)
downloadzig-clap-a305e818bd986c599fff17141617bc4f890276cf.tar.gz
zig-clap-a305e818bd986c599fff17141617bc4f890276cf.tar.xz
zig-clap-a305e818bd986c599fff17141617bc4f890276cf.zip
Add clap.parse as the simplest way of using the lib
Diffstat (limited to 'example/simple-error.zig')
-rw-r--r--example/simple-error.zig15
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 @@
1const std = @import("std");
2const clap = @import("clap");
3
4pub 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}