diff options
| author | 2019-08-06 18:38:56 +0200 | |
|---|---|---|
| committer | 2019-08-06 18:38:56 +0200 | |
| commit | bf18f2a1f72570aca94a6d3e4703f5f54a2e090b (patch) | |
| tree | d06d34639f8d8d69830719be22d7c79d6875814a /src | |
| parent | Embed examples in README during build (diff) | |
| download | zig-clap-bf18f2a1f72570aca94a6d3e4703f5f54a2e090b.tar.gz zig-clap-bf18f2a1f72570aca94a6d3e4703f5f54a2e090b.tar.xz zig-clap-bf18f2a1f72570aca94a6d3e4703f5f54a2e090b.zip | |
build with latest version of zig
Diffstat (limited to 'src')
| -rw-r--r-- | src/comptime.zig | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/comptime.zig b/src/comptime.zig index d872b82..3220ad6 100644 --- a/src/comptime.zig +++ b/src/comptime.zig | |||
| @@ -11,19 +11,12 @@ pub fn ComptimeClap(comptime Id: type, comptime params: []const clap.Param(Id)) | |||
| 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 | const index = blk: { | 14 | var index: usize = 0; |
| 15 | if (param.names.long == null and param.names.short == null) | 15 | if (param.names.long != null or param.names.short != null) { |
| 16 | break :blk 0; | 16 | const ptr = if (param.takes_value) &options else &flags; |
| 17 | if (param.takes_value) { | 17 | index = ptr.*; |
| 18 | const res = options; | 18 | ptr.* += 1; |
| 19 | options += 1; | 19 | } |
| 20 | break :blk res; | ||
| 21 | } | ||
| 22 | |||
| 23 | const res = flags; | ||
| 24 | flags += 1; | ||
| 25 | break :blk res; | ||
| 26 | }; | ||
| 27 | 20 | ||
| 28 | const converted = clap.Param(usize){ | 21 | const converted = clap.Param(usize){ |
| 29 | .id = index, | 22 | .id = index, |