diff options
| author | 2023-04-02 06:10:40 -0500 | |
|---|---|---|
| committer | 2023-04-02 13:10:40 +0200 | |
| commit | ab69ef2db44b6c4b7f00283d52d38fbe71d16c42 (patch) | |
| tree | 10416c0cdda32ba98d54954940c440beac6ccf08 /README.md | |
| parent | Update build script to actually run the tests (diff) | |
| download | zig-clap-ab69ef2db44b6c4b7f00283d52d38fbe71d16c42.tar.gz zig-clap-ab69ef2db44b6c4b7f00283d52d38fbe71d16c42.tar.xz zig-clap-ab69ef2db44b6c4b7f00283d52d38fbe71d16c42.zip | |
Count occurrences of flags (was "Add .count type for flags") (#96)
Breaking change: parseEx now counts the number of occurrences of flag
parameters (those with takes_value == .none) and returns the count as a
u8. Users of the library will need to change
if (arg_result.my_flag)
to
if (arg_result.my_flag != 0)
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 9 |
1 files changed, 5 insertions, 4 deletions
| @@ -14,6 +14,7 @@ in the release notes. | |||
| 14 | 14 | ||
| 15 | * Short arguments `-a` | 15 | * Short arguments `-a` |
| 16 | * Chaining `-abc` where `a` and `b` does not take values. | 16 | * Chaining `-abc` where `a` and `b` does not take values. |
| 17 | * Multiple specifications are tallied (e.g. `-v -v`). | ||
| 17 | * Long arguments `--long` | 18 | * Long arguments `--long` |
| 18 | * Supports both passing values using spacing and `=` (`-a 100`, `-a=100`) | 19 | * Supports both passing values using spacing and `=` (`-a 100`, `-a=100`) |
| 19 | * Short args also support passing values with no spacing or `=` (`-a100`) | 20 | * Short args also support passing values with no spacing or `=` (`-a100`) |
| @@ -59,7 +60,7 @@ pub fn main() !void { | |||
| 59 | }; | 60 | }; |
| 60 | defer res.deinit(); | 61 | defer res.deinit(); |
| 61 | 62 | ||
| 62 | if (res.args.help) | 63 | if (res.args.help != 0) |
| 63 | debug.print("--help\n", .{}); | 64 | debug.print("--help\n", .{}); |
| 64 | if (res.args.number) |n| | 65 | if (res.args.number) |n| |
| 65 | debug.print("--number = {}\n", .{n}); | 66 | debug.print("--number = {}\n", .{n}); |
| @@ -121,7 +122,7 @@ pub fn main() !void { | |||
| 121 | }; | 122 | }; |
| 122 | defer res.deinit(); | 123 | defer res.deinit(); |
| 123 | 124 | ||
| 124 | if (res.args.help) | 125 | if (res.args.help != 0) |
| 125 | debug.print("--help\n", .{}); | 126 | debug.print("--help\n", .{}); |
| 126 | if (res.args.number) |n| | 127 | if (res.args.number) |n| |
| 127 | debug.print("--number = {}\n", .{n}); | 128 | debug.print("--number = {}\n", .{n}); |
| @@ -231,7 +232,7 @@ pub fn main() !void { | |||
| 231 | // where `Id` has a `describtion` and `value` method (`Param(Help)` is one such parameter). | 232 | // where `Id` has a `describtion` and `value` method (`Param(Help)` is one such parameter). |
| 232 | // The last argument contains options as to how `help` should print those parameters. Using | 233 | // The last argument contains options as to how `help` should print those parameters. Using |
| 233 | // `.{}` means the default options. | 234 | // `.{}` means the default options. |
| 234 | if (res.args.help) | 235 | if (res.args.help != 0) |
| 235 | return clap.help(std.io.getStdErr().writer(), clap.Help, ¶ms, .{}); | 236 | return clap.help(std.io.getStdErr().writer(), clap.Help, ¶ms, .{}); |
| 236 | } | 237 | } |
| 237 | 238 | ||
| @@ -268,7 +269,7 @@ pub fn main() !void { | |||
| 268 | 269 | ||
| 269 | // `clap.usage` is a function that can print a simple help message. It can print any `Param` | 270 | // `clap.usage` is a function that can print a simple help message. It can print any `Param` |
| 270 | // where `Id` has a `value` method (`Param(Help)` is one such parameter). | 271 | // where `Id` has a `value` method (`Param(Help)` is one such parameter). |
| 271 | if (res.args.help) | 272 | if (res.args.help != 0) |
| 272 | return clap.usage(std.io.getStdErr().writer(), clap.Help, ¶ms); | 273 | return clap.usage(std.io.getStdErr().writer(), clap.Help, ¶ms); |
| 273 | } | 274 | } |
| 274 | 275 | ||