summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jimmi Holst Christensen2019-08-17 18:56:16 +0200
committerGravatar Jimmi Holst Christensen2019-08-17 18:56:16 +0200
commit2df5a2abb89be57cbe48eaa920c19304d77b046c (patch)
tree9ab5a5fe2757e70b6836f211c4e96be127767e99
parentrebuild readme (diff)
downloadzig-clap-2df5a2abb89be57cbe48eaa920c19304d77b046c.tar.gz
zig-clap-2df5a2abb89be57cbe48eaa920c19304d77b046c.tar.xz
zig-clap-2df5a2abb89be57cbe48eaa920c19304d77b046c.zip
correct comptime-clap-error.zig example
-rw-r--r--README.md12
-rw-r--r--example/README.md.template6
-rw-r--r--example/comptime-clap-error.zig6
3 files changed, 10 insertions, 14 deletions
diff --git a/README.md b/README.md
index 297764c..ce83cf0 100644
--- a/README.md
+++ b/README.md
@@ -133,14 +133,12 @@ const std = @import("std");
133const clap = @import("clap"); 133const clap = @import("clap");
134 134
135pub fn main() !void { 135pub 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```
157zig-clap/src/comptime.zig:116:17: error: --helps is not a parameter. 155zig-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 ^
160zig-clap/src/comptime.zig:84:45: note: called from here 158zig-clap/src/comptime.zig:77:45: note: called from here
161 const param = comptime findParam(name); 159 const param = comptime findParam(name);
162 ^ 160 ^
163zig-clap/example/comptime-clap-error.zig:22:18: note: called from here 161zig-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```
45zig-clap/src/comptime.zig:116:17: error: --helps is not a parameter. 45zig-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 ^
48zig-clap/src/comptime.zig:84:45: note: called from here 48zig-clap/src/comptime.zig:77:45: note: called from here
49 const param = comptime findParam(name); 49 const param = comptime findParam(name);
50 ^ 50 ^
51zig-clap/example/comptime-clap-error.zig:22:18: note: called from here 51zig-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");
2const clap = @import("clap"); 2const clap = @import("clap");
3 3
4pub fn main() !void { 4pub 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();