diff options
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 | } |