From 1367cb885cd91f47559060f10af94981dcc908f4 Mon Sep 17 00:00:00 2001 From: Jimmi Holst Christensen Date: Wed, 7 Nov 2018 08:19:48 +0100 Subject: Run tests in all release modes --- .travis.yml | 4 +++- 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: script: - zig-linux-*/zig version - zig-linux-*/zig test test.zig - + - zig-linux-*/zig test test.zig --release-fast + - zig-linux-*/zig test test.zig --release-safe + - zig-linux-*/zig test test.zig --release-small diff --git a/clap.zig b/clap.zig index 06c860e..26b97aa 100644 --- a/clap.zig +++ b/clap.zig @@ -93,7 +93,7 @@ pub const Names = struct { /// * Value parameters must take a value. pub fn Param(comptime Id: type) type { return struct { - const Self = @This(); + const Self = @This(); id: Id, takes_value: bool, @@ -119,7 +119,7 @@ pub fn Param(comptime Id: type) type { /// The result returned from ::StreamingClap.next pub fn Arg(comptime Id: type) type { return struct { - const Self = @This(); + const Self = @This(); param: *const Param(Id), value: ?[]const u8, @@ -136,7 +136,7 @@ pub fn Arg(comptime Id: type) type { /// A interface for iterating over command line arguments pub fn ArgIterator(comptime E: type) type { return struct { - const Self = @This(); + const Self = @This(); const Error = E; nextFn: fn (iter: *Self) Error!?[]const u8, @@ -373,4 +373,27 @@ pub fn StreamingClap(comptime Id: type, comptime ArgError: type) type { return error.InvalidArgument; } }; -} \ No newline at end of file +} + +pub fn ToStructId(comptime T: type) type { + return struct { + parse: fn(*T, ?[]const u8) + }; +} + +const ToStructParamError = error{}; +const ToStructParam = Param(fn (*T, ?[]const u8) ToStructParamError!void); + +fn paramsFromStruct(comptime T: type) []const ToStructParam { + var res: []const ToStructParam = []ToStructParam{}; + + for (@typeInfo(T).Struct.fields) |field| { + res = res ++ []ToStructParam{ + ToStructParam.init() + }; + } +} + +pub fn toStruct(defaults: var, iter: *ArgIterator(ArgError)) !@typeOf(defaults) { + +} -- cgit v1.2.3