diff options
Diffstat (limited to 'example/help.zig')
| -rw-r--r-- | example/help.zig | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/example/help.zig b/example/help.zig index d90373a..de3b707 100644 --- a/example/help.zig +++ b/example/help.zig | |||
| @@ -2,14 +2,17 @@ const clap = @import("clap"); | |||
| 2 | const std = @import("std"); | 2 | const std = @import("std"); |
| 3 | 3 | ||
| 4 | pub fn main() !void { | 4 | pub fn main() !void { |
| 5 | const params = comptime [_]clap.Param(clap.Help){ | ||
| 6 | clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, | ||
| 7 | clap.parseParam("-v, --version Output version information and exit.") catch unreachable, | ||
| 8 | }; | ||
| 9 | |||
| 10 | var args = try clap.parse(clap.Help, ¶ms, .{}); | ||
| 11 | defer args.deinit(); | ||
| 12 | |||
| 5 | // clap.help is a function that can print a simple help message, given a | 13 | // clap.help is a function that can print a simple help message, given a |
| 6 | // slice of Param(Help). There is also a helpEx, which can print a | 14 | // slice of Param(Help). There is also a helpEx, which can print a |
| 7 | // help message for any Param, but it is more verbose to call. | 15 | // help message for any Param, but it is more verbose to call. |
| 8 | try clap.help( | 16 | if (args.flag("--help")) |
| 9 | std.io.getStdErr().writer(), | 17 | return clap.help(std.io.getStdErr().writer(), ¶ms); |
| 10 | comptime &.{ | ||
| 11 | clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, | ||
| 12 | clap.parseParam("-v, --version Output version information and exit.") catch unreachable, | ||
| 13 | }, | ||
| 14 | ); | ||
| 15 | } | 18 | } |