diff options
| author | 2020-08-28 17:26:01 +1000 | |
|---|---|---|
| committer | 2020-08-28 09:43:42 +0200 | |
| commit | a3d2a261f59983838e3ed5f01d90f18352e6a421 (patch) | |
| tree | 834fb4e483fd92a6b6d29ca89482fbfb87b7089a /example/simple.zig | |
| parent | reverse the order of these (diff) | |
| download | zig-clap-a3d2a261f59983838e3ed5f01d90f18352e6a421.tar.gz zig-clap-a3d2a261f59983838e3ed5f01d90f18352e6a421.tar.xz zig-clap-a3d2a261f59983838e3ed5f01d90f18352e6a421.zip | |
adjust examples, README template
Diffstat (limited to 'example/simple.zig')
| -rw-r--r-- | example/simple.zig | 9 |
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 | } |