From c7d83fcce1739271e399260b50c5f68aa03c5908 Mon Sep 17 00:00:00 2001 From: Komari Spaghetti Date: Wed, 26 May 2021 21:06:10 +0200 Subject: Update to latest zig in preperation for 0.8.0 --- example/README.md.template | 10 +++++----- example/help.zig | 2 +- example/simple-ex.zig | 10 +++------- example/simple.zig | 6 +++--- example/streaming-clap.zig | 10 +++------- example/usage.zig | 2 +- 6 files changed, 16 insertions(+), 24 deletions(-) (limited to 'example') diff --git a/example/README.md.template b/example/README.md.template index 530cea4..74a2f1d 100644 --- a/example/README.md.template +++ b/example/README.md.template @@ -25,7 +25,7 @@ into master on every `zig` release. The simplest way to use this library is to just call the `clap.parse` function. ```zig -{} +{s} ``` The data structure returned has lookup speed on par with array access (`arr[i]`) and validates @@ -33,7 +33,7 @@ that the strings you pass to `option`, `options` and `flag` are actually paramet program can take: ```zig -{} +{s} ``` ``` @@ -58,7 +58,7 @@ The `StreamingClap` is the base of all the other parsers. It's a streaming parse `args.Iterator` to provide it with arguments lazily. ```zig -{} +{s} ``` Currently, this parse is the only parser that allow an array of `Param` tha @@ -70,7 +70,7 @@ The `help`, `helpEx` and `helpFull` are functions for printing a simple list of program can take. ```zig -{} +{s} ``` ``` @@ -93,7 +93,7 @@ The `usage`, `usageEx` and `usageFull` are functions for printing a small abbrev of the help message. ```zig -{} +{s} ``` ``` diff --git a/example/help.zig b/example/help.zig index 3cf9e42..d90373a 100644 --- a/example/help.zig +++ b/example/help.zig @@ -7,7 +7,7 @@ pub fn main() !void { // help message for any Param, but it is more verbose to call. try clap.help( std.io.getStdErr().writer(), - comptime &[_]clap.Param(clap.Help){ + comptime &.{ clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, clap.parseParam("-v, --version Output version information and exit.") catch unreachable, }, diff --git a/example/simple-ex.zig b/example/simple-ex.zig index 88598aa..838b9c2 100644 --- a/example/simple-ex.zig +++ b/example/simple-ex.zig @@ -30,11 +30,7 @@ pub fn main() !void { .diagnostic = &diag, }) catch |err| { // Report useful error and exit -<<<<<<< HEAD - diag.report(std.io.getStdErr().writer(), err) catch {}; -======= diag.report(io.getStdErr().writer(), err) catch {}; ->>>>>>> master return err; }; defer args.deinit(); @@ -42,9 +38,9 @@ pub fn main() !void { if (args.flag("--help")) debug.warn("--help\n", .{}); if (args.option("--number")) |n| - debug.warn("--number = {}\n", .{n}); + debug.warn("--number = {s}\n", .{n}); for (args.options("--string")) |s| - debug.warn("--string = {}\n", .{s}); + debug.warn("--string = {s}\n", .{s}); for (args.positionals()) |pos| - debug.warn("{}\n", .{pos}); + debug.warn("{s}\n", .{pos}); } diff --git a/example/simple.zig b/example/simple.zig index 69473fa..78a963c 100644 --- a/example/simple.zig +++ b/example/simple.zig @@ -28,9 +28,9 @@ pub fn main() !void { if (args.flag("--help")) debug.warn("--help\n", .{}); if (args.option("--number")) |n| - debug.warn("--number = {}\n", .{n}); + debug.warn("--number = {s}\n", .{n}); for (args.options("--string")) |s| - debug.warn("--string = {}\n", .{s}); + debug.warn("--string = {s}\n", .{s}); for (args.positionals()) |pos| - debug.warn("{}\n", .{pos}); + debug.warn("{s}\n", .{pos}); } diff --git a/example/streaming-clap.zig b/example/streaming-clap.zig index 32d44c4..5f7f219 100644 --- a/example/streaming-clap.zig +++ b/example/streaming-clap.zig @@ -39,22 +39,18 @@ pub fn main() !void { // Because we use a streaming parser, we have to consume each argument parsed individually. while (parser.next() catch |err| { // Report useful error and exit -<<<<<<< HEAD - diag.report(std.io.getStdErr().writer(), err) catch {}; -======= diag.report(io.getStdErr().writer(), err) catch {}; ->>>>>>> master return err; }) |arg| { // arg.param will point to the parameter which matched the argument. switch (arg.param.id) { 'h' => debug.warn("Help!\n", .{}), - 'n' => debug.warn("--number = {}\n", .{arg.value.?}), + 'n' => debug.warn("--number = {s}\n", .{arg.value.?}), - // arg.value == null, if arg.param.takes_value == false. + // arg.value == null, if arg.param.takes_value == .none. // Otherwise, arg.value is the value passed with the argument, such as "-a=10" // or "-a 10". - 'f' => debug.warn("{}\n", .{arg.value.?}), + 'f' => debug.warn("{s}\n", .{arg.value.?}), else => unreachable, } } diff --git a/example/usage.zig b/example/usage.zig index e044f1d..7956570 100644 --- a/example/usage.zig +++ b/example/usage.zig @@ -7,7 +7,7 @@ pub fn main() !void { // usage message for any Param, but it is more verbose to call. try clap.usage( std.io.getStdErr().writer(), - comptime &[_]clap.Param(clap.Help){ + comptime &.{ clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, clap.parseParam("-v, --version Output version information and exit.") catch unreachable, clap.parseParam(" --value Output version information and exit.") catch unreachable, -- cgit v1.2.3