diff options
| author | 2019-09-05 23:51:59 +0200 | |
|---|---|---|
| committer | 2019-09-05 23:51:59 +0200 | |
| commit | 25ddbaea75ec88b409057546b79bd95526790964 (patch) | |
| tree | 0eb93a3ba3f0e6589ba1cbe25c6932801d0693b7 | |
| parent | always interpret '-' and '--' as positionals (diff) | |
| download | zig-clap-25ddbaea75ec88b409057546b79bd95526790964.tar.gz zig-clap-25ddbaea75ec88b409057546b79bd95526790964.tar.xz zig-clap-25ddbaea75ec88b409057546b79bd95526790964.zip | |
use emun literals
| -rw-r--r-- | clap.zig | 2 | ||||
| -rw-r--r-- | src/streaming.zig | 9 |
2 files changed, 5 insertions, 6 deletions
| @@ -55,7 +55,7 @@ pub fn Param(comptime Id: type) type { | |||
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | /// Takes a string and parses it to a Param(Help). | 57 | /// Takes a string and parses it to a Param(Help). |
| 58 | /// This is the reverse of 'help2' but for at single parameter only. | 58 | /// This is the reverse of 'help' but for at single parameter only. |
| 59 | pub fn parseParam(line: []const u8) !Param(Help) { | 59 | pub fn parseParam(line: []const u8) !Param(Help) { |
| 60 | var res = Param(Help){ | 60 | var res = Param(Help){ |
| 61 | .id = Help{ | 61 | .id = Help{ |
diff --git a/src/streaming.zig b/src/streaming.zig index 884a270..b5c3498 100644 --- a/src/streaming.zig +++ b/src/streaming.zig | |||
| @@ -51,7 +51,7 @@ pub fn StreamingClap(comptime Id: type, comptime ArgIterator: type) type { | |||
| 51 | }; | 51 | }; |
| 52 | 52 | ||
| 53 | switch (parser.state) { | 53 | switch (parser.state) { |
| 54 | State.Normal => { | 54 | .Normal => { |
| 55 | const full_arg = (try parser.iter.next()) orelse return null; | 55 | const full_arg = (try parser.iter.next()) orelse return null; |
| 56 | const arg_info = if (mem.eql(u8, full_arg, "--") or mem.eql(u8, full_arg, "-")) | 56 | const arg_info = if (mem.eql(u8, full_arg, "--") or mem.eql(u8, full_arg, "-")) |
| 57 | ArgInfo{ .arg = full_arg, .kind = .Positional } | 57 | ArgInfo{ .arg = full_arg, .kind = .Positional } |
| @@ -112,7 +112,7 @@ pub fn StreamingClap(comptime Id: type, comptime ArgIterator: type) type { | |||
| 112 | 112 | ||
| 113 | return error.InvalidArgument; | 113 | return error.InvalidArgument; |
| 114 | }, | 114 | }, |
| 115 | @TagType(State).Chaining => |state| return try parser.chainging(state), | 115 | .Chaining => |state| return try parser.chainging(state), |
| 116 | } | 116 | } |
| 117 | } | 117 | } |
| 118 | 118 | ||
| @@ -177,9 +177,8 @@ fn testNoErr(params: []const clap.Param(u8), args_strings: []const []const u8, r | |||
| 177 | testing.expectEqualSlices(u8, expected_value, actual_value); | 177 | testing.expectEqualSlices(u8, expected_value, actual_value); |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | if (c.next() catch @panic("")) |_| { | 180 | if (c.next() catch unreachable) |_| |
| 181 | @panic(""); | 181 | unreachable; |
| 182 | } | ||
| 183 | } | 182 | } |
| 184 | 183 | ||
| 185 | test "clap.streaming.StreamingClap: short params" { | 184 | test "clap.streaming.StreamingClap: short params" { |