summaryrefslogtreecommitdiff
path: root/example/simple.zig
diff options
context:
space:
mode:
authorGravatar Asherah Connor2020-08-28 17:26:01 +1000
committerGravatar Jimmi Holst Christensen2020-09-06 17:33:25 +0200
commit620b680c4d03cec7209d25e4019cf29a033dcb26 (patch)
tree93e8fc8ca9e87f0b29042c71b0bafa45f006fe31 /example/simple.zig
parentreverse the order of these (diff)
downloadzig-clap-620b680c4d03cec7209d25e4019cf29a033dcb26.tar.gz
zig-clap-620b680c4d03cec7209d25e4019cf29a033dcb26.tar.xz
zig-clap-620b680c4d03cec7209d25e4019cf29a033dcb26.zip
adjust examples, README template
Diffstat (limited to 'example/simple.zig')
-rw-r--r--example/simple.zig9
1 files changed, 6 insertions, 3 deletions
diff --git a/example/simple.zig b/example/simple.zig
index 3510317..adea9f9 100644
--- a/example/simple.zig
+++ b/example/simple.zig
@@ -7,10 +7,11 @@ pub fn main() !void {
7 // First we specify what parameters our program can take. 7 // First we specify what parameters our program can take.
8 // We can use `parseParam` to parse a string to a `Param(Help)` 8 // We can use `parseParam` to parse a string to a `Param(Help)`
9 const params = comptime [_]clap.Param(clap.Help){ 9 const params = comptime [_]clap.Param(clap.Help){
10 clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, 10 clap.parseParam("-h, --help Display this help and exit. ") catch unreachable,
11 clap.parseParam("-n, --number <NUM> An option parameter, which takes a value.") catch unreachable, 11 clap.parseParam("-n, --number <NUM> An option parameter, which takes a value.") catch unreachable,
12 clap.parseParam("-s, --string <STR>... An option parameter which can be specified multiple times.") catch unreachable,
12 clap.Param(clap.Help){ 13 clap.Param(clap.Help){
13 .takes_value = true, 14 .takes_value = .One,
14 }, 15 },
15 }; 16 };
16 17
@@ -21,6 +22,8 @@ pub fn main() !void {
21 debug.warn("--help\n", .{}); 22 debug.warn("--help\n", .{});
22 if (args.option("--number")) |n| 23 if (args.option("--number")) |n|
23 debug.warn("--number = {}\n", .{n}); 24 debug.warn("--number = {}\n", .{n});
25 for (args.options("--string")) |s|
26 debug.warn("--string = {}\n", .{s});
24 for (args.positionals()) |pos| 27 for (args.positionals()) |pos|
25 debug.warn("{}\n", .{pos}); 28 debug.warn("{}\n", .{pos});
26} 29}