summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jimmi Holst Christensen2020-04-11 14:30:34 +0200
committerGravatar GitHub2020-04-11 14:30:34 +0200
commit96fbd8db260492d4cbc1fb2b592aad164c18edb0 (patch)
tree060424c76c70ec0643a2181b6ac0cbbddd54a4ed
parentMerge pull request #16 from joachimschmidt557/zig-master (diff)
parentrebuild readme (diff)
downloadzig-clap-96fbd8db260492d4cbc1fb2b592aad164c18edb0.tar.gz
zig-clap-96fbd8db260492d4cbc1fb2b592aad164c18edb0.tar.xz
zig-clap-96fbd8db260492d4cbc1fb2b592aad164c18edb0.zip
Merge pull request #17 from joachimschmidt557/zig-master
update examples to latest zig
-rw-r--r--README.md9
-rw-r--r--build.zig2
-rw-r--r--example/comptime-clap.zig2
-rw-r--r--example/help.zig3
-rw-r--r--example/simple.zig2
-rw-r--r--example/streaming-clap.zig2
6 files changed, 9 insertions, 11 deletions
diff --git a/README.md b/README.md
index e5ec35c..642856b 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@ pub fn main() !void {
36 }, 36 },
37 }; 37 };
38 38
39 var args = try clap.parse(clap.Help, &params, std.heap.direct_allocator); 39 var args = try clap.parse(clap.Help, &params, std.heap.page_allocator);
40 defer args.deinit(); 40 defer args.deinit();
41 41
42 if (args.flag("--help")) 42 if (args.flag("--help"))
@@ -97,7 +97,7 @@ const clap = @import("clap");
97const debug = std.debug; 97const debug = std.debug;
98 98
99pub fn main() !void { 99pub fn main() !void {
100 const allocator = std.heap.direct_allocator; 100 const allocator = std.heap.page_allocator;
101 101
102 // First we specify what parameters our program can take. 102 // First we specify what parameters our program can take.
103 // We can use `parseParam` to parse a string to a `Param(Help)` 103 // We can use `parseParam` to parse a string to a `Param(Help)`
@@ -140,7 +140,7 @@ const clap = @import("clap");
140const debug = std.debug; 140const debug = std.debug;
141 141
142pub fn main() !void { 142pub fn main() !void {
143 const allocator = std.heap.direct_allocator; 143 const allocator = std.heap.page_allocator;
144 144
145 // First we specify what parameters our program can take. 145 // First we specify what parameters our program can take.
146 const params = [_]clap.Param(u8){ 146 const params = [_]clap.Param(u8){
@@ -203,13 +203,12 @@ const clap = @import("clap");
203pub fn main() !void { 203pub fn main() !void {
204 const stderr_file = std.io.getStdErr(); 204 const stderr_file = std.io.getStdErr();
205 var stderr_out_stream = stderr_file.outStream(); 205 var stderr_out_stream = stderr_file.outStream();
206 const stderr = &stderr_out_stream.stream;
207 206
208 // clap.help is a function that can print a simple help message, given a 207 // clap.help is a function that can print a simple help message, given a
209 // slice of Param(Help). There is also a helpEx, which can print a 208 // slice of Param(Help). There is also a helpEx, which can print a
210 // help message for any Param, but it is more verbose to call. 209 // help message for any Param, but it is more verbose to call.
211 try clap.help( 210 try clap.help(
212 stderr, 211 stderr_out_stream,
213 comptime &[_]clap.Param(clap.Help){ 212 comptime &[_]clap.Param(clap.Help){
214 clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, 213 clap.parseParam("-h, --help Display this help and exit. ") catch unreachable,
215 clap.parseParam("-v, --version Output version information and exit.") catch unreachable, 214 clap.parseParam("-v, --version Output version information and exit.") catch unreachable,
diff --git a/build.zig b/build.zig
index 30aa733..6adfbf4 100644
--- a/build.zig
+++ b/build.zig
@@ -40,7 +40,7 @@ pub fn build(b: *Builder) void {
40 example_step.dependOn(&example.step); 40 example_step.dependOn(&example.step);
41 } 41 }
42 42
43 const readme_step = b.step("test", "Remake README."); 43 const readme_step = b.step("readme", "Remake README.");
44 const readme = readMeStep(b); 44 const readme = readMeStep(b);
45 readme.dependOn(example_step); 45 readme.dependOn(example_step);
46 readme_step.dependOn(readme); 46 readme_step.dependOn(readme);
diff --git a/example/comptime-clap.zig b/example/comptime-clap.zig
index a030368..f5c0221 100644
--- a/example/comptime-clap.zig
+++ b/example/comptime-clap.zig
@@ -4,7 +4,7 @@ const clap = @import("clap");
4const debug = std.debug; 4const debug = std.debug;
5 5
6pub fn main() !void { 6pub fn main() !void {
7 const allocator = std.heap.direct_allocator; 7 const allocator = std.heap.page_allocator;
8 8
9 // First we specify what parameters our program can take. 9 // First we specify what parameters our program can take.
10 // We can use `parseParam` to parse a string to a `Param(Help)` 10 // We can use `parseParam` to parse a string to a `Param(Help)`
diff --git a/example/help.zig b/example/help.zig
index 1191482..2775177 100644
--- a/example/help.zig
+++ b/example/help.zig
@@ -4,13 +4,12 @@ const clap = @import("clap");
4pub fn main() !void { 4pub fn main() !void {
5 const stderr_file = std.io.getStdErr(); 5 const stderr_file = std.io.getStdErr();
6 var stderr_out_stream = stderr_file.outStream(); 6 var stderr_out_stream = stderr_file.outStream();
7 const stderr = &stderr_out_stream.stream;
8 7
9 // clap.help is a function that can print a simple help message, given a 8 // clap.help is a function that can print a simple help message, given a
10 // slice of Param(Help). There is also a helpEx, which can print a 9 // slice of Param(Help). There is also a helpEx, which can print a
11 // help message for any Param, but it is more verbose to call. 10 // help message for any Param, but it is more verbose to call.
12 try clap.help( 11 try clap.help(
13 stderr, 12 stderr_out_stream,
14 comptime &[_]clap.Param(clap.Help){ 13 comptime &[_]clap.Param(clap.Help){
15 clap.parseParam("-h, --help Display this help and exit. ") catch unreachable, 14 clap.parseParam("-h, --help Display this help and exit. ") catch unreachable,
16 clap.parseParam("-v, --version Output version information and exit.") catch unreachable, 15 clap.parseParam("-v, --version Output version information and exit.") catch unreachable,
diff --git a/example/simple.zig b/example/simple.zig
index 5ac204d..d546223 100644
--- a/example/simple.zig
+++ b/example/simple.zig
@@ -14,7 +14,7 @@ pub fn main() !void {
14 }, 14 },
15 }; 15 };
16 16
17 var args = try clap.parse(clap.Help, &params, std.heap.direct_allocator); 17 var args = try clap.parse(clap.Help, &params, std.heap.page_allocator);
18 defer args.deinit(); 18 defer args.deinit();
19 19
20 if (args.flag("--help")) 20 if (args.flag("--help"))
diff --git a/example/streaming-clap.zig b/example/streaming-clap.zig
index b277266..4cc43d1 100644
--- a/example/streaming-clap.zig
+++ b/example/streaming-clap.zig
@@ -4,7 +4,7 @@ const clap = @import("clap");
4const debug = std.debug; 4const debug = std.debug;
5 5
6pub fn main() !void { 6pub fn main() !void {
7 const allocator = std.heap.direct_allocator; 7 const allocator = std.heap.page_allocator;
8 8
9 // First we specify what parameters our program can take. 9 // First we specify what parameters our program can take.
10 const params = [_]clap.Param(u8){ 10 const params = [_]clap.Param(u8){