diff options
| author | 2019-12-01 23:10:25 -0800 | |
|---|---|---|
| committer | 2019-12-01 23:20:09 -0800 | |
| commit | 2174a4a2e617e51fea42e114803538b9bedb9d35 (patch) | |
| tree | 7d76dca13427d585cff36c38230d368e51fb3c20 /clap/comptime.zig | |
| parent | Add clap.parse as the simplest way of using the lib (diff) | |
| download | zig-clap-2174a4a2e617e51fea42e114803538b9bedb9d35.tar.gz zig-clap-2174a4a2e617e51fea42e114803538b9bedb9d35.tar.xz zig-clap-2174a4a2e617e51fea42e114803538b9bedb9d35.zip | |
update for latest zig
Diffstat (limited to 'clap/comptime.zig')
| -rw-r--r-- | clap/comptime.zig | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/clap/comptime.zig b/clap/comptime.zig index f5c2762..c25659b 100644 --- a/clap/comptime.zig +++ b/clap/comptime.zig | |||
| @@ -9,7 +9,7 @@ const debug = std.debug; | |||
| 9 | pub fn ComptimeClap(comptime Id: type, comptime params: []const clap.Param(Id)) type { | 9 | pub fn ComptimeClap(comptime Id: type, comptime params: []const clap.Param(Id)) type { |
| 10 | var flags: usize = 0; | 10 | var flags: usize = 0; |
| 11 | var options: usize = 0; | 11 | var options: usize = 0; |
| 12 | var converted_params: []const clap.Param(usize) = [_]clap.Param(usize){}; | 12 | var converted_params: []const clap.Param(usize) = &[_]clap.Param(usize){}; |
| 13 | for (params) |param| { | 13 | for (params) |param| { |
| 14 | var index: usize = 0; | 14 | var index: usize = 0; |
| 15 | if (param.names.long != null or param.names.short != null) { | 15 | if (param.names.long != null or param.names.short != null) { |
| @@ -113,7 +113,7 @@ pub fn ComptimeClap(comptime Id: type, comptime params: []const clap.Param(Id)) | |||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | test "clap.comptime.ComptimeClap" { | 115 | test "clap.comptime.ComptimeClap" { |
| 116 | const Clap = ComptimeClap(clap.Help, comptime [_]clap.Param(clap.Help){ | 116 | const Clap = ComptimeClap(clap.Help, comptime &[_]clap.Param(clap.Help){ |
| 117 | clap.parseParam("-a, --aa ") catch unreachable, | 117 | clap.parseParam("-a, --aa ") catch unreachable, |
| 118 | clap.parseParam("-b, --bb ") catch unreachable, | 118 | clap.parseParam("-b, --bb ") catch unreachable, |
| 119 | clap.parseParam("-c, --cc <V>") catch unreachable, | 119 | clap.parseParam("-c, --cc <V>") catch unreachable, |
| @@ -125,7 +125,7 @@ test "clap.comptime.ComptimeClap" { | |||
| 125 | var buf: [1024]u8 = undefined; | 125 | var buf: [1024]u8 = undefined; |
| 126 | var fb_allocator = heap.FixedBufferAllocator.init(buf[0..]); | 126 | var fb_allocator = heap.FixedBufferAllocator.init(buf[0..]); |
| 127 | var iter = clap.args.SliceIterator{ | 127 | var iter = clap.args.SliceIterator{ |
| 128 | .args = [_][]const u8{ | 128 | .args = &[_][]const u8{ |
| 129 | "-a", "-c", "0", "something", | 129 | "-a", "-c", "0", "something", |
| 130 | }, | 130 | }, |
| 131 | }; | 131 | }; |
| @@ -138,6 +138,6 @@ test "clap.comptime.ComptimeClap" { | |||
| 138 | testing.expect(!args.flag("--bb")); | 138 | testing.expect(!args.flag("--bb")); |
| 139 | testing.expectEqualSlices(u8, "0", args.option("-c").?); | 139 | testing.expectEqualSlices(u8, "0", args.option("-c").?); |
| 140 | testing.expectEqualSlices(u8, "0", args.option("--cc").?); | 140 | testing.expectEqualSlices(u8, "0", args.option("--cc").?); |
| 141 | testing.expectEqual(usize(1), args.positionals().len); | 141 | testing.expectEqual(@as(usize, 1), args.positionals().len); |
| 142 | testing.expectEqualSlices(u8, "something", args.positionals()[0]); | 142 | testing.expectEqualSlices(u8, "something", args.positionals()[0]); |
| 143 | } | 143 | } |