diff options
Diffstat (limited to 'example')
| -rw-r--r-- | example/README.md.template | 10 | ||||
| -rw-r--r-- | example/help.zig | 2 | ||||
| -rw-r--r-- | example/simple-ex.zig | 10 | ||||
| -rw-r--r-- | example/simple.zig | 6 | ||||
| -rw-r--r-- | example/streaming-clap.zig | 10 | ||||
| -rw-r--r-- | example/usage.zig | 2 |
6 files changed, 16 insertions, 24 deletions
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. | |||
| 25 | The simplest way to use this library is to just call the `clap.parse` function. | 25 | The simplest way to use this library is to just call the `clap.parse` function. |
| 26 | 26 | ||
| 27 | ```zig | 27 | ```zig |
| 28 | {} | 28 | {s} |
| 29 | ``` | 29 | ``` |
| 30 | 30 | ||
| 31 | The data structure returned has lookup speed on par with array access (`arr[i]`) and validates | 31 | 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 | |||
| 33 | program can take: | 33 | program can take: |
| 34 | 34 | ||
| 35 | ```zig | 35 | ```zig |
| 36 | {} | 36 | {s} |
| 37 | ``` | 37 | ``` |
| 38 | 38 | ||
| 39 | ``` | 39 | ``` |
| @@ -58,7 +58,7 @@ The `StreamingClap` is the base of all the other parsers. It's a streaming parse | |||
| 58 | `args.Iterator` to provide it with arguments lazily. | 58 | `args.Iterator` to provide it with arguments lazily. |
| 59 | 59 | ||
| 60 | ```zig | 60 | ```zig |
| 61 | {} | 61 | {s} |
| 62 | ``` | 62 | ``` |
| 63 | 63 | ||
| 64 | Currently, this parse is the only parser that allow an array of `Param` tha | 64 | 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 | |||
| 70 | program can take. | 70 | program can take. |
| 71 | 71 | ||
| 72 | ```zig | 72 | ```zig |
| 73 | {} | 73 | {s} |
| 74 | ``` | 74 | ``` |
| 75 | 75 | ||
| 76 | ``` | 76 | ``` |
| @@ -93,7 +93,7 @@ The `usage`, `usageEx` and `usageFull` are functions for printing a small abbrev | |||
| 93 | of the help message. | 93 | of the help message. |
| 94 | 94 | ||
| 95 | ```zig | 95 | ```zig |
| 96 | {} | 96 | {s} |
| 97 | ``` | 97 | ``` |
| 98 | 98 | ||
| 99 | ``` | 99 | ``` |
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 { | |||
| 7 | // help message for any Param, but it is more verbose to call. | 7 | // help message for any Param, but it is more verbose to call. |
| 8 | try clap.help( | 8 | try clap.help( |
| 9 | std.io.getStdErr().writer(), | 9 | std.io.getStdErr().writer(), |
| 10 | comptime &[_]clap.Param(clap.Help){ | 10 | comptime &.{ |
| 11 | clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, | 11 | clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, |
| 12 | clap.parseParam("-v, --version Output version information and exit.") catch unreachable, | 12 | clap.parseParam("-v, --version Output version information and exit.") catch unreachable, |
| 13 | }, | 13 | }, |
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 { | |||
| 30 | .diagnostic = &diag, | 30 | .diagnostic = &diag, |
| 31 | }) catch |err| { | 31 | }) catch |err| { |
| 32 | // Report useful error and exit | 32 | // Report useful error and exit |
| 33 | <<<<<<< HEAD | ||
| 34 | diag.report(std.io.getStdErr().writer(), err) catch {}; | ||
| 35 | ======= | ||
| 36 | diag.report(io.getStdErr().writer(), err) catch {}; | 33 | diag.report(io.getStdErr().writer(), err) catch {}; |
| 37 | >>>>>>> master | ||
| 38 | return err; | 34 | return err; |
| 39 | }; | 35 | }; |
| 40 | defer args.deinit(); | 36 | defer args.deinit(); |
| @@ -42,9 +38,9 @@ pub fn main() !void { | |||
| 42 | if (args.flag("--help")) | 38 | if (args.flag("--help")) |
| 43 | debug.warn("--help\n", .{}); | 39 | debug.warn("--help\n", .{}); |
| 44 | if (args.option("--number")) |n| | 40 | if (args.option("--number")) |n| |
| 45 | debug.warn("--number = {}\n", .{n}); | 41 | debug.warn("--number = {s}\n", .{n}); |
| 46 | for (args.options("--string")) |s| | 42 | for (args.options("--string")) |s| |
| 47 | debug.warn("--string = {}\n", .{s}); | 43 | debug.warn("--string = {s}\n", .{s}); |
| 48 | for (args.positionals()) |pos| | 44 | for (args.positionals()) |pos| |
| 49 | debug.warn("{}\n", .{pos}); | 45 | debug.warn("{s}\n", .{pos}); |
| 50 | } | 46 | } |
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 { | |||
| 28 | if (args.flag("--help")) | 28 | if (args.flag("--help")) |
| 29 | debug.warn("--help\n", .{}); | 29 | debug.warn("--help\n", .{}); |
| 30 | if (args.option("--number")) |n| | 30 | if (args.option("--number")) |n| |
| 31 | debug.warn("--number = {}\n", .{n}); | 31 | debug.warn("--number = {s}\n", .{n}); |
| 32 | for (args.options("--string")) |s| | 32 | for (args.options("--string")) |s| |
| 33 | debug.warn("--string = {}\n", .{s}); | 33 | debug.warn("--string = {s}\n", .{s}); |
| 34 | for (args.positionals()) |pos| | 34 | for (args.positionals()) |pos| |
| 35 | debug.warn("{}\n", .{pos}); | 35 | debug.warn("{s}\n", .{pos}); |
| 36 | } | 36 | } |
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 { | |||
| 39 | // Because we use a streaming parser, we have to consume each argument parsed individually. | 39 | // Because we use a streaming parser, we have to consume each argument parsed individually. |
| 40 | while (parser.next() catch |err| { | 40 | while (parser.next() catch |err| { |
| 41 | // Report useful error and exit | 41 | // Report useful error and exit |
| 42 | <<<<<<< HEAD | ||
| 43 | diag.report(std.io.getStdErr().writer(), err) catch {}; | ||
| 44 | ======= | ||
| 45 | diag.report(io.getStdErr().writer(), err) catch {}; | 42 | diag.report(io.getStdErr().writer(), err) catch {}; |
| 46 | >>>>>>> master | ||
| 47 | return err; | 43 | return err; |
| 48 | }) |arg| { | 44 | }) |arg| { |
| 49 | // arg.param will point to the parameter which matched the argument. | 45 | // arg.param will point to the parameter which matched the argument. |
| 50 | switch (arg.param.id) { | 46 | switch (arg.param.id) { |
| 51 | 'h' => debug.warn("Help!\n", .{}), | 47 | 'h' => debug.warn("Help!\n", .{}), |
| 52 | 'n' => debug.warn("--number = {}\n", .{arg.value.?}), | 48 | 'n' => debug.warn("--number = {s}\n", .{arg.value.?}), |
| 53 | 49 | ||
| 54 | // arg.value == null, if arg.param.takes_value == false. | 50 | // arg.value == null, if arg.param.takes_value == .none. |
| 55 | // Otherwise, arg.value is the value passed with the argument, such as "-a=10" | 51 | // Otherwise, arg.value is the value passed with the argument, such as "-a=10" |
| 56 | // or "-a 10". | 52 | // or "-a 10". |
| 57 | 'f' => debug.warn("{}\n", .{arg.value.?}), | 53 | 'f' => debug.warn("{s}\n", .{arg.value.?}), |
| 58 | else => unreachable, | 54 | else => unreachable, |
| 59 | } | 55 | } |
| 60 | } | 56 | } |
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 { | |||
| 7 | // usage message for any Param, but it is more verbose to call. | 7 | // usage message for any Param, but it is more verbose to call. |
| 8 | try clap.usage( | 8 | try clap.usage( |
| 9 | std.io.getStdErr().writer(), | 9 | std.io.getStdErr().writer(), |
| 10 | comptime &[_]clap.Param(clap.Help){ | 10 | comptime &.{ |
| 11 | clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, | 11 | clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, |
| 12 | clap.parseParam("-v, --version Output version information and exit.") catch unreachable, | 12 | clap.parseParam("-v, --version Output version information and exit.") catch unreachable, |
| 13 | clap.parseParam(" --value <N> Output version information and exit.") catch unreachable, | 13 | clap.parseParam(" --value <N> Output version information and exit.") catch unreachable, |