diff options
| author | 2018-11-07 08:19:48 +0100 | |
|---|---|---|
| committer | 2018-11-07 08:19:48 +0100 | |
| commit | 1367cb885cd91f47559060f10af94981dcc908f4 (patch) | |
| tree | a68776510f243265ebeac6b586e67f8cd3aa82c4 | |
| parent | Renamed Clap to StreamingClap (diff) | |
| download | zig-clap-1367cb885cd91f47559060f10af94981dcc908f4.tar.gz zig-clap-1367cb885cd91f47559060f10af94981dcc908f4.tar.xz zig-clap-1367cb885cd91f47559060f10af94981dcc908f4.zip | |
Run tests in all release modes
| -rw-r--r-- | .travis.yml | 4 | ||||
| -rw-r--r-- | clap.zig | 31 |
2 files changed, 30 insertions, 5 deletions
diff --git a/.travis.yml b/.travis.yml index 2253826..48e7273 100644 --- a/.travis.yml +++ b/.travis.yml | |||
| @@ -9,4 +9,6 @@ git: | |||
| 9 | script: | 9 | script: |
| 10 | - zig-linux-*/zig version | 10 | - zig-linux-*/zig version |
| 11 | - zig-linux-*/zig test test.zig | 11 | - zig-linux-*/zig test test.zig |
| 12 | 12 | - zig-linux-*/zig test test.zig --release-fast | |
| 13 | - zig-linux-*/zig test test.zig --release-safe | ||
| 14 | - zig-linux-*/zig test test.zig --release-small | ||
| @@ -93,7 +93,7 @@ pub const Names = struct { | |||
| 93 | /// * Value parameters must take a value. | 93 | /// * Value parameters must take a value. |
| 94 | pub fn Param(comptime Id: type) type { | 94 | pub fn Param(comptime Id: type) type { |
| 95 | return struct { | 95 | return struct { |
| 96 | const Self = @This(); | 96 | const Self = @This(); |
| 97 | 97 | ||
| 98 | id: Id, | 98 | id: Id, |
| 99 | takes_value: bool, | 99 | takes_value: bool, |
| @@ -119,7 +119,7 @@ pub fn Param(comptime Id: type) type { | |||
| 119 | /// The result returned from ::StreamingClap.next | 119 | /// The result returned from ::StreamingClap.next |
| 120 | pub fn Arg(comptime Id: type) type { | 120 | pub fn Arg(comptime Id: type) type { |
| 121 | return struct { | 121 | return struct { |
| 122 | const Self = @This(); | 122 | const Self = @This(); |
| 123 | 123 | ||
| 124 | param: *const Param(Id), | 124 | param: *const Param(Id), |
| 125 | value: ?[]const u8, | 125 | value: ?[]const u8, |
| @@ -136,7 +136,7 @@ pub fn Arg(comptime Id: type) type { | |||
| 136 | /// A interface for iterating over command line arguments | 136 | /// A interface for iterating over command line arguments |
| 137 | pub fn ArgIterator(comptime E: type) type { | 137 | pub fn ArgIterator(comptime E: type) type { |
| 138 | return struct { | 138 | return struct { |
| 139 | const Self = @This(); | 139 | const Self = @This(); |
| 140 | const Error = E; | 140 | const Error = E; |
| 141 | 141 | ||
| 142 | nextFn: fn (iter: *Self) Error!?[]const u8, | 142 | nextFn: fn (iter: *Self) Error!?[]const u8, |
| @@ -373,4 +373,27 @@ pub fn StreamingClap(comptime Id: type, comptime ArgError: type) type { | |||
| 373 | return error.InvalidArgument; | 373 | return error.InvalidArgument; |
| 374 | } | 374 | } |
| 375 | }; | 375 | }; |
| 376 | } \ No newline at end of file | 376 | } |
| 377 | |||
| 378 | pub fn ToStructId(comptime T: type) type { | ||
| 379 | return struct { | ||
| 380 | parse: fn(*T, ?[]const u8) | ||
| 381 | }; | ||
| 382 | } | ||
| 383 | |||
| 384 | const ToStructParamError = error{}; | ||
| 385 | const ToStructParam = Param(fn (*T, ?[]const u8) ToStructParamError!void); | ||
| 386 | |||
| 387 | fn paramsFromStruct(comptime T: type) []const ToStructParam { | ||
| 388 | var res: []const ToStructParam = []ToStructParam{}; | ||
| 389 | |||
| 390 | for (@typeInfo(T).Struct.fields) |field| { | ||
| 391 | res = res ++ []ToStructParam{ | ||
| 392 | ToStructParam.init() | ||
| 393 | }; | ||
| 394 | } | ||
| 395 | } | ||
| 396 | |||
| 397 | pub fn toStruct(defaults: var, iter: *ArgIterator(ArgError)) !@typeOf(defaults) { | ||
| 398 | |||
| 399 | } | ||