summaryrefslogtreecommitdiff
path: root/example/help.zig
diff options
context:
space:
mode:
authorGravatar Jimmi Holst Christensen2022-02-25 19:40:00 +0100
committerGravatar Jimmi Holst Christensen2022-02-25 19:40:00 +0100
commitcfaac64c404fb1c2e892880410aa3b7dd881ea58 (patch)
tree0dca149e43daaaef41f55fa61375ab361c36a39c /example/help.zig
parentFix minor typos in README.md (diff)
downloadzig-clap-cfaac64c404fb1c2e892880410aa3b7dd881ea58.tar.gz
zig-clap-cfaac64c404fb1c2e892880410aa3b7dd881ea58.tar.xz
zig-clap-cfaac64c404fb1c2e892880410aa3b7dd881ea58.zip
Change clap into generating a struct
This changes - `.flag`, `.option`, `.options` and `.positionals` are now just fields you access. - Move the current `clap.parse` and friends into `clap.untyped.parse` - This is in preperation for `clap.typed.parse`
Diffstat (limited to 'example/help.zig')
-rw-r--r--example/help.zig10
1 files changed, 5 insertions, 5 deletions
diff --git a/example/help.zig b/example/help.zig
index de3b707..2e7ca2b 100644
--- a/example/help.zig
+++ b/example/help.zig
@@ -3,16 +3,16 @@ const std = @import("std");
3 3
4pub fn main() !void { 4pub fn main() !void {
5 const params = comptime [_]clap.Param(clap.Help){ 5 const params = comptime [_]clap.Param(clap.Help){
6 clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, 6 clap.untyped.parseParam("-h, --help Display this help and exit. ") catch unreachable,
7 clap.parseParam("-v, --version Output version information and exit.") catch unreachable, 7 clap.untyped.parseParam("-v, --version Output version information and exit.") catch unreachable,
8 }; 8 };
9 9
10 var args = try clap.parse(clap.Help, &params, .{}); 10 var res = try clap.untyped.parse(clap.Help, &params, .{});
11 defer args.deinit(); 11 defer res.deinit();
12 12
13 // 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
14 // 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
15 // 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.
16 if (args.flag("--help")) 16 if (res.args.help)
17 return clap.help(std.io.getStdErr().writer(), &params); 17 return clap.help(std.io.getStdErr().writer(), &params);
18} 18}