summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorGravatar Devin J. Pohly2023-04-02 06:10:40 -0500
committerGravatar GitHub2023-04-02 13:10:40 +0200
commitab69ef2db44b6c4b7f00283d52d38fbe71d16c42 (patch)
tree10416c0cdda32ba98d54954940c440beac6ccf08 /example
parentUpdate build script to actually run the tests (diff)
downloadzig-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 'example')
-rw-r--r--example/README.md.template1
-rw-r--r--example/help.zig2
-rw-r--r--example/simple-ex.zig2
-rw-r--r--example/simple.zig2
-rw-r--r--example/usage.zig2
5 files changed, 5 insertions, 4 deletions
diff --git a/example/README.md.template b/example/README.md.template
index 696c598..34bff56 100644
--- a/example/README.md.template
+++ b/example/README.md.template
@@ -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`)
diff --git a/example/help.zig b/example/help.zig
index dd9c9ea..e83ae44 100644
--- a/example/help.zig
+++ b/example/help.zig
@@ -15,6 +15,6 @@ pub fn main() !void {
15 // where `Id` has a `describtion` and `value` method (`Param(Help)` is one such parameter). 15 // where `Id` has a `describtion` and `value` method (`Param(Help)` is one such parameter).
16 // The last argument contains options as to how `help` should print those parameters. Using 16 // The last argument contains options as to how `help` should print those parameters. Using
17 // `.{}` means the default options. 17 // `.{}` means the default options.
18 if (res.args.help) 18 if (res.args.help != 0)
19 return clap.help(std.io.getStdErr().writer(), clap.Help, &params, .{}); 19 return clap.help(std.io.getStdErr().writer(), clap.Help, &params, .{});
20} 20}
diff --git a/example/simple-ex.zig b/example/simple-ex.zig
index fb20d07..dd5d929 100644
--- a/example/simple-ex.zig
+++ b/example/simple-ex.zig
@@ -36,7 +36,7 @@ pub fn main() !void {
36 }; 36 };
37 defer res.deinit(); 37 defer res.deinit();
38 38
39 if (res.args.help) 39 if (res.args.help != 0)
40 debug.print("--help\n", .{}); 40 debug.print("--help\n", .{});
41 if (res.args.number) |n| 41 if (res.args.number) |n|
42 debug.print("--number = {}\n", .{n}); 42 debug.print("--number = {}\n", .{n});
diff --git a/example/simple.zig b/example/simple.zig
index 2d32463..429f095 100644
--- a/example/simple.zig
+++ b/example/simple.zig
@@ -28,7 +28,7 @@ pub fn main() !void {
28 }; 28 };
29 defer res.deinit(); 29 defer res.deinit();
30 30
31 if (res.args.help) 31 if (res.args.help != 0)
32 debug.print("--help\n", .{}); 32 debug.print("--help\n", .{});
33 if (res.args.number) |n| 33 if (res.args.number) |n|
34 debug.print("--number = {}\n", .{n}); 34 debug.print("--number = {}\n", .{n});
diff --git a/example/usage.zig b/example/usage.zig
index 0d21352..333536b 100644
--- a/example/usage.zig
+++ b/example/usage.zig
@@ -14,6 +14,6 @@ pub fn main() !void {
14 14
15 // `clap.usage` is a function that can print a simple help message. It can print any `Param` 15 // `clap.usage` is a function that can print a simple help message. It can print any `Param`
16 // where `Id` has a `value` method (`Param(Help)` is one such parameter). 16 // where `Id` has a `value` method (`Param(Help)` is one such parameter).
17 if (res.args.help) 17 if (res.args.help != 0)
18 return clap.usage(std.io.getStdErr().writer(), clap.Help, &params); 18 return clap.usage(std.io.getStdErr().writer(), clap.Help, &params);
19} 19}