summaryrefslogtreecommitdiff
path: root/example/usage.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/usage.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 '')
-rw-r--r--example/usage.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/example/usage.zig b/example/usage.zig
index 368a6b3..04fedba 100644
--- a/example/usage.zig
+++ b/example/usage.zig
@@ -3,17 +3,17 @@ 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 clap.parseParam(" --value <N> An option parameter, which takes a value.") catch unreachable, 8 clap.untyped.parseParam(" --value <N> An option parameter, which takes a value.") catch unreachable,
9 }; 9 };
10 10
11 var args = try clap.parse(clap.Help, &params, .{}); 11 var res = try clap.untyped.parse(clap.Help, &params, .{});
12 defer args.deinit(); 12 defer res.deinit();
13 13
14 // clap.usage is a function that can print a simple usage message, given a 14 // clap.usage is a function that can print a simple usage message, given a
15 // slice of Param(Help). There is also a usageEx, which can print a 15 // slice of Param(Help). There is also a usageEx, which can print a
16 // usage message for any Param, but it is more verbose to call. 16 // usage message for any Param, but it is more verbose to call.
17 if (args.flag("--help")) 17 if (res.args.help)
18 return clap.usage(std.io.getStdErr().writer(), &params); 18 return clap.usage(std.io.getStdErr().writer(), &params);
19} 19}