summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jimmi Holst Christensen2018-09-17 14:24:41 +0200
committerGravatar Jimmi Holst Christensen2018-09-17 14:24:41 +0200
commit9c8af684933070270a0abfba673d5ba5cbc5f983 (patch)
tree2af3c2340c7e7c15f4b1a8d05c15bfc20853d226
parentFix failed compile on windows (diff)
downloadzig-clap-9c8af684933070270a0abfba673d5ba5cbc5f983.tar.gz
zig-clap-9c8af684933070270a0abfba673d5ba5cbc5f983.tar.xz
zig-clap-9c8af684933070270a0abfba673d5ba5cbc5f983.zip
Renamed Clap to StreamingClap
-rw-r--r--clap.zig10
-rw-r--r--test.zig6
2 files changed, 8 insertions, 8 deletions
diff --git a/clap.zig b/clap.zig
index 6c21dba..06c860e 100644
--- a/clap.zig
+++ b/clap.zig
@@ -116,7 +116,7 @@ pub fn Param(comptime Id: type) type {
116 }; 116 };
117} 117}
118 118
119/// The result returned from ::Clap.next 119/// The result returned from ::StreamingClap.next
120pub fn Arg(comptime Id: type) type { 120pub fn Arg(comptime Id: type) type {
121 return struct { 121 return struct {
122 const Self = @This(); 122 const Self = @This();
@@ -206,9 +206,9 @@ pub const OsArgIterator = struct {
206}; 206};
207 207
208/// A command line argument parser which, given an ::ArgIterator, will parse arguments according 208/// A command line argument parser which, given an ::ArgIterator, will parse arguments according
209/// to the ::params. ::Clap parses in an iterating manner, so you have to use a loop together with 209/// to the ::params. ::StreamingClap parses in an iterating manner, so you have to use a loop together with
210/// ::Clap.next to parse all the arguments of your program. 210/// ::StreamingClap.next to parse all the arguments of your program.
211pub fn Clap(comptime Id: type, comptime ArgError: type) type { 211pub fn StreamingClap(comptime Id: type, comptime ArgError: type) type {
212 return struct { 212 return struct {
213 const Self = @This(); 213 const Self = @This();
214 214
@@ -373,4 +373,4 @@ pub fn Clap(comptime Id: type, comptime ArgError: type) type {
373 return error.InvalidArgument; 373 return error.InvalidArgument;
374 } 374 }
375 }; 375 };
376} 376} \ No newline at end of file
diff --git a/test.zig b/test.zig
index c42fbb9..70bbab1 100644
--- a/test.zig
+++ b/test.zig
@@ -9,12 +9,12 @@ const assert = debug.assert;
9const ArgSliceIterator = clap.ArgSliceIterator; 9const ArgSliceIterator = clap.ArgSliceIterator;
10const Names = clap.Names; 10const Names = clap.Names;
11const Param = clap.Param(u8); 11const Param = clap.Param(u8);
12const Clap = clap.Clap(u8, ArgSliceIterator.Error); 12const StreamingClap = clap.StreamingClap(u8, ArgSliceIterator.Error);
13const Arg = clap.Arg(u8); 13const Arg = clap.Arg(u8);
14 14
15fn testNoErr(params: []const Param, args: []const []const u8, results: []const Arg) void { 15fn testNoErr(params: []const Param, args: []const []const u8, results: []const Arg) void {
16 var arg_iter = ArgSliceIterator.init(args); 16 var arg_iter = ArgSliceIterator.init(args);
17 var c = Clap.init(params, &arg_iter.iter); 17 var c = StreamingClap.init(params, &arg_iter.iter);
18 18
19 for (results) |res| { 19 for (results) |res| {
20 const arg = (c.next() catch unreachable) orelse unreachable; 20 const arg = (c.next() catch unreachable) orelse unreachable;
@@ -224,7 +224,7 @@ test "clap.Example" {
224 // a slice of arguments. For real program, you would probably 224 // a slice of arguments. For real program, you would probably
225 // use `OsArgIterator`. 225 // use `OsArgIterator`.
226 var iter = &c.ArgSliceIterator.init(program_args).iter; 226 var iter = &c.ArgSliceIterator.init(program_args).iter;
227 var parser = c.Clap(u8, c.ArgSliceIterator.Error).init(params, iter); 227 var parser = c.StreamingClap(u8, c.ArgSliceIterator.Error).init(params, iter);
228 228
229 // Iterate over all arguments passed to the program. 229 // Iterate over all arguments passed to the program.
230 // In real code, you should probably handle the errors 230 // In real code, you should probably handle the errors