diff options
| author | 2020-08-28 17:26:01 +1000 | |
|---|---|---|
| committer | 2020-08-28 09:43:42 +0200 | |
| commit | a3d2a261f59983838e3ed5f01d90f18352e6a421 (patch) | |
| tree | 834fb4e483fd92a6b6d29ca89482fbfb87b7089a /example/comptime-clap.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 '')
| -rw-r--r-- | example/comptime-clap.zig | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/example/comptime-clap.zig b/example/comptime-clap.zig index d5c84fe..d709e48 100644 --- a/example/comptime-clap.zig +++ b/example/comptime-clap.zig | |||
| @@ -9,10 +9,11 @@ pub fn main() !void { | |||
| 9 | // First we specify what parameters our program can take. | 9 | // First we specify what parameters our program can take. |
| 10 | // We can use `parseParam` to parse a string to a `Param(Help)` | 10 | // We can use `parseParam` to parse a string to a `Param(Help)` |
| 11 | const params = comptime [_]clap.Param(clap.Help){ | 11 | const params = comptime [_]clap.Param(clap.Help){ |
| 12 | clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, | 12 | clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, |
| 13 | clap.parseParam("-n, --number <NUM> An option parameter, which takes a value.") catch unreachable, | 13 | clap.parseParam("-n, --number <NUM> An option parameter, which takes a value.") catch unreachable, |
| 14 | clap.parseParam("-s, --string <STR>... An option parameter which can be specified multiple times.") catch unreachable, | ||
| 14 | clap.Param(clap.Help){ | 15 | clap.Param(clap.Help){ |
| 15 | .takes_value = true, | 16 | .takes_value = .One, |
| 16 | }, | 17 | }, |
| 17 | }; | 18 | }; |
| 18 | 19 | ||
| @@ -29,6 +30,8 @@ pub fn main() !void { | |||
| 29 | debug.warn("--help\n", .{}); | 30 | debug.warn("--help\n", .{}); |
| 30 | if (args.option("--number")) |n| | 31 | if (args.option("--number")) |n| |
| 31 | debug.warn("--number = {}\n", .{n}); | 32 | debug.warn("--number = {}\n", .{n}); |
| 33 | for (args.options("--string")) |s| | ||
| 34 | debug.warn("--string = {}\n", .{s}); | ||
| 32 | for (args.positionals()) |pos| | 35 | for (args.positionals()) |pos| |
| 33 | debug.warn("{}\n", .{pos}); | 36 | debug.warn("{}\n", .{pos}); |
| 34 | } | 37 | } |