summaryrefslogtreecommitdiff
path: root/example/simple.zig
diff options
context:
space:
mode:
authorGravatar Jimmi Holst Christensen2022-03-23 20:05:28 +0100
committerGravatar Komari Spaghetti2022-03-23 21:48:20 +0100
commit5166a15378a9c32d9b680417807000ba65d06141 (patch)
treebf5b37a04d9bd41128971e7bfd5e1dccef30bb36 /example/simple.zig
parentRefactor parseParam into a state machine (diff)
downloadzig-clap-5166a15378a9c32d9b680417807000ba65d06141.tar.gz
zig-clap-5166a15378a9c32d9b680417807000ba65d06141.tar.xz
zig-clap-5166a15378a9c32d9b680417807000ba65d06141.zip
Add parseParams and friends
Diffstat (limited to '')
-rw-r--r--example/simple.zig15
1 files changed, 8 insertions, 7 deletions
diff --git a/example/simple.zig b/example/simple.zig
index 11e975e..1ac7de5 100644
--- a/example/simple.zig
+++ b/example/simple.zig
@@ -6,13 +6,14 @@ const io = std.io;
6 6
7pub fn main() !void { 7pub fn main() !void {
8 // First we specify what parameters our program can take. 8 // First we specify what parameters our program can take.
9 // We can use `parseParam` to parse a string to a `Param(Help)` 9 // We can use `parseParamsComptime` to parse a string into an array of `Param(Help)`
10 const params = comptime [_]clap.Param(clap.Help){ 10 const params = comptime clap.parseParamsComptime(
11 clap.parseParam("-h, --help Display this help and exit.") catch unreachable, 11 \\-h, --help Display this help and exit.
12 clap.parseParam("-n, --number <usize> An option parameter, which takes a value.") catch unreachable, 12 \\-n, --number <usize> An option parameter, which takes a value.
13 clap.parseParam("-s, --string <str>... An option parameter which can be specified multiple times.") catch unreachable, 13 \\-s, --string <str>... An option parameter which can be specified multiple times.
14 clap.parseParam("<str>...") catch unreachable, 14 \\<str>...
15 }; 15 \\
16 );
16 17
17 // Initalize our diagnostics, which can be used for reporting useful errors. 18 // Initalize our diagnostics, which can be used for reporting useful errors.
18 // This is optional. You can also pass `.{}` to `clap.parse` if you don't 19 // This is optional. You can also pass `.{}` to `clap.parse` if you don't