diff options
| author | 2022-03-30 22:04:15 +0200 | |
|---|---|---|
| committer | 2022-03-30 22:04:15 +0200 | |
| commit | ac5f46541ca47d3db9df0fcef3cc61731adaefab (patch) | |
| tree | 6fde8d5846540eaa63f6f11bd9527c8fecdb441b | |
| parent | New `help` api that provides options as to how paramters are printed. (diff) | |
| download | zig-clap-ac5f46541ca47d3db9df0fcef3cc61731adaefab.tar.gz zig-clap-ac5f46541ca47d3db9df0fcef3cc61731adaefab.tar.xz zig-clap-ac5f46541ca47d3db9df0fcef3cc61731adaefab.zip | |
Update help and usage examples
Diffstat (limited to '')
| -rw-r--r-- | README.md | 12 | ||||
| -rw-r--r-- | example/help.zig | 7 | ||||
| -rw-r--r-- | example/usage.zig | 5 |
3 files changed, 12 insertions, 12 deletions
| @@ -217,9 +217,10 @@ pub fn main() !void { | |||
| 217 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{}); | 217 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{}); |
| 218 | defer res.deinit(); | 218 | defer res.deinit(); |
| 219 | 219 | ||
| 220 | // clap.help is a function that can print a simple help message, given a | 220 | // `clap.help` is a function that can print a simple help message. It can print any `Param` |
| 221 | // slice of Param(Help). There is also a helpEx, which can print a | 221 | // where `Id` has a `describtion` and `value` method (`Param(Help)` is one such parameter). |
| 222 | // help message for any Param, but it is more verbose to call. | 222 | // The last argument contains options as to how `help` should print those parameters. Using |
| 223 | // `.{}` means the default options. | ||
| 223 | if (res.args.help) | 224 | if (res.args.help) |
| 224 | return clap.help(std.io.getStdErr().writer(), clap.Help, ¶ms, .{}); | 225 | return clap.help(std.io.getStdErr().writer(), clap.Help, ¶ms, .{}); |
| 225 | } | 226 | } |
| @@ -255,9 +256,8 @@ pub fn main() !void { | |||
| 255 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{}); | 256 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{}); |
| 256 | defer res.deinit(); | 257 | defer res.deinit(); |
| 257 | 258 | ||
| 258 | // clap.usage is a function that can print a simple usage message, given a | 259 | // `clap.usage` is a function that can print a simple help message. It can print any `Param` |
| 259 | // slice of Param(Help). There is also a usageEx, which can print a | 260 | // where `Id` has a `value` method (`Param(Help)` is one such parameter). |
| 260 | // usage message for any Param, but it is more verbose to call. | ||
| 261 | if (res.args.help) | 261 | if (res.args.help) |
| 262 | return clap.usage(std.io.getStdErr().writer(), clap.Help, ¶ms); | 262 | return clap.usage(std.io.getStdErr().writer(), clap.Help, ¶ms); |
| 263 | } | 263 | } |
diff --git a/example/help.zig b/example/help.zig index 18d61b9..dd9c9ea 100644 --- a/example/help.zig +++ b/example/help.zig | |||
| @@ -11,9 +11,10 @@ pub fn main() !void { | |||
| 11 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{}); | 11 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{}); |
| 12 | defer res.deinit(); | 12 | defer res.deinit(); |
| 13 | 13 | ||
| 14 | // clap.help is a function that can print a simple help message, given a | 14 | // `clap.help` is a function that can print a simple help message. It can print any `Param` |
| 15 | // slice of Param(Help). There is also a helpEx, which can print a | 15 | // where `Id` has a `describtion` and `value` method (`Param(Help)` is one such parameter). |
| 16 | // help message for any Param, but it is more verbose to call. | 16 | // The last argument contains options as to how `help` should print those parameters. Using |
| 17 | // `.{}` means the default options. | ||
| 17 | if (res.args.help) | 18 | if (res.args.help) |
| 18 | return clap.help(std.io.getStdErr().writer(), clap.Help, ¶ms, .{}); | 19 | return clap.help(std.io.getStdErr().writer(), clap.Help, ¶ms, .{}); |
| 19 | } | 20 | } |
diff --git a/example/usage.zig b/example/usage.zig index f57b07c..0d21352 100644 --- a/example/usage.zig +++ b/example/usage.zig | |||
| @@ -12,9 +12,8 @@ pub fn main() !void { | |||
| 12 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{}); | 12 | var res = try clap.parse(clap.Help, ¶ms, clap.parsers.default, .{}); |
| 13 | defer res.deinit(); | 13 | defer res.deinit(); |
| 14 | 14 | ||
| 15 | // clap.usage is a function that can print a simple usage message, given a | 15 | // `clap.usage` is a function that can print a simple help message. It can print any `Param` |
| 16 | // slice of Param(Help). There is also a usageEx, which can print a | 16 | // where `Id` has a `value` method (`Param(Help)` is one such parameter). |
| 17 | // usage message for any Param, but it is more verbose to call. | ||
| 18 | if (res.args.help) | 17 | if (res.args.help) |
| 19 | return clap.usage(std.io.getStdErr().writer(), clap.Help, ¶ms); | 18 | return clap.usage(std.io.getStdErr().writer(), clap.Help, ¶ms); |
| 20 | } | 19 | } |