diff options
| author | 2019-08-17 18:56:16 +0200 | |
|---|---|---|
| committer | 2019-08-17 18:56:16 +0200 | |
| commit | 2df5a2abb89be57cbe48eaa920c19304d77b046c (patch) | |
| tree | 9ab5a5fe2757e70b6836f211c4e96be127767e99 | |
| parent | rebuild readme (diff) | |
| download | zig-clap-2df5a2abb89be57cbe48eaa920c19304d77b046c.tar.gz zig-clap-2df5a2abb89be57cbe48eaa920c19304d77b046c.tar.xz zig-clap-2df5a2abb89be57cbe48eaa920c19304d77b046c.zip | |
correct comptime-clap-error.zig example
| -rw-r--r-- | README.md | 12 | ||||
| -rw-r--r-- | example/README.md.template | 6 | ||||
| -rw-r--r-- | example/comptime-clap-error.zig | 6 |
3 files changed, 10 insertions, 14 deletions
| @@ -133,14 +133,12 @@ const std = @import("std"); | |||
| 133 | const clap = @import("clap"); | 133 | const clap = @import("clap"); |
| 134 | 134 | ||
| 135 | pub fn main() !void { | 135 | pub fn main() !void { |
| 136 | const allocator = std.heap.direct_allocator; | ||
| 137 | |||
| 136 | const params = [_]clap.Param(void){clap.Param(void){ | 138 | const params = [_]clap.Param(void){clap.Param(void){ |
| 137 | .names = clap.Names{ .short = 'h', .long = "help" }, | 139 | .names = clap.Names{ .short = 'h', .long = "help" }, |
| 138 | }}; | 140 | }}; |
| 139 | 141 | ||
| 140 | var direct_allocator = std.heap.DirectAllocator.init(); | ||
| 141 | const allocator = &direct_allocator.allocator; | ||
| 142 | defer direct_allocator.deinit(); | ||
| 143 | |||
| 144 | var iter = clap.args.OsIterator.init(allocator); | 142 | var iter = clap.args.OsIterator.init(allocator); |
| 145 | defer iter.deinit(); | 143 | defer iter.deinit(); |
| 146 | const exe = try iter.next(); | 144 | const exe = try iter.next(); |
| @@ -154,13 +152,13 @@ pub fn main() !void { | |||
| 154 | ``` | 152 | ``` |
| 155 | 153 | ||
| 156 | ``` | 154 | ``` |
| 157 | zig-clap/src/comptime.zig:116:17: error: --helps is not a parameter. | 155 | zig-clap/src/comptime.zig:109:17: error: --helps is not a parameter. |
| 158 | @compileError(name ++ " is not a parameter."); | 156 | @compileError(name ++ " is not a parameter."); |
| 159 | ^ | 157 | ^ |
| 160 | zig-clap/src/comptime.zig:84:45: note: called from here | 158 | zig-clap/src/comptime.zig:77:45: note: called from here |
| 161 | const param = comptime findParam(name); | 159 | const param = comptime findParam(name); |
| 162 | ^ | 160 | ^ |
| 163 | zig-clap/example/comptime-clap-error.zig:22:18: note: called from here | 161 | zig-clap/example/comptime-clap-error.zig:18:18: note: called from here |
| 164 | _ = args.flag("--helps"); | 162 | _ = args.flag("--helps"); |
| 165 | ^ | 163 | ^ |
| 166 | ``` | 164 | ``` |
diff --git a/example/README.md.template b/example/README.md.template index 7963112..373a037 100644 --- a/example/README.md.template +++ b/example/README.md.template | |||
| @@ -42,13 +42,13 @@ program can take: | |||
| 42 | ``` | 42 | ``` |
| 43 | 43 | ||
| 44 | ``` | 44 | ``` |
| 45 | zig-clap/src/comptime.zig:116:17: error: --helps is not a parameter. | 45 | zig-clap/src/comptime.zig:109:17: error: --helps is not a parameter. |
| 46 | @compileError(name ++ " is not a parameter."); | 46 | @compileError(name ++ " is not a parameter."); |
| 47 | ^ | 47 | ^ |
| 48 | zig-clap/src/comptime.zig:84:45: note: called from here | 48 | zig-clap/src/comptime.zig:77:45: note: called from here |
| 49 | const param = comptime findParam(name); | 49 | const param = comptime findParam(name); |
| 50 | ^ | 50 | ^ |
| 51 | zig-clap/example/comptime-clap-error.zig:22:18: note: called from here | 51 | zig-clap/example/comptime-clap-error.zig:18:18: note: called from here |
| 52 | _ = args.flag("--helps"); | 52 | _ = args.flag("--helps"); |
| 53 | ^ | 53 | ^ |
| 54 | ``` | 54 | ``` |
diff --git a/example/comptime-clap-error.zig b/example/comptime-clap-error.zig index 93c1af2..3209b74 100644 --- a/example/comptime-clap-error.zig +++ b/example/comptime-clap-error.zig | |||
| @@ -2,14 +2,12 @@ const std = @import("std"); | |||
| 2 | const clap = @import("clap"); | 2 | const clap = @import("clap"); |
| 3 | 3 | ||
| 4 | pub fn main() !void { | 4 | pub fn main() !void { |
| 5 | const allocator = std.heap.direct_allocator; | ||
| 6 | |||
| 5 | const params = [_]clap.Param(void){clap.Param(void){ | 7 | const params = [_]clap.Param(void){clap.Param(void){ |
| 6 | .names = clap.Names{ .short = 'h', .long = "help" }, | 8 | .names = clap.Names{ .short = 'h', .long = "help" }, |
| 7 | }}; | 9 | }}; |
| 8 | 10 | ||
| 9 | var direct_allocator = std.heap.DirectAllocator.init(); | ||
| 10 | const allocator = &direct_allocator.allocator; | ||
| 11 | defer direct_allocator.deinit(); | ||
| 12 | |||
| 13 | var iter = clap.args.OsIterator.init(allocator); | 11 | var iter = clap.args.OsIterator.init(allocator); |
| 14 | defer iter.deinit(); | 12 | defer iter.deinit(); |
| 15 | const exe = try iter.next(); | 13 | const exe = try iter.next(); |