Adds support for enumeration items, resolves #2.
This commit is contained in:
parent
430e9e1155
commit
55fb4c6c8e
3
args.zig
3
args.zig
|
@ -122,7 +122,7 @@ fn requiresArg(comptime T: type) bool {
|
|||
return true;
|
||||
|
||||
return switch (@as(std.builtin.TypeId, @typeInfo(Type))) {
|
||||
.Int, .Float => true,
|
||||
.Int, .Float, .Enum => true,
|
||||
.Bool => false,
|
||||
else => @compileError(@typeName(Type) ++ " is not a supported argument type!"),
|
||||
};
|
||||
|
@ -148,6 +148,7 @@ fn convertArgumentValue(comptime T: type, textInput: []const u8) !T {
|
|||
else
|
||||
try std.fmt.parseUnsigned(T, textInput, 10),
|
||||
.Float => return try std.fmt.parseFloat(T, textInput),
|
||||
.Enum => return std.meta.stringToEnum(T, textInput) orelse return error.InvalidEnumeration,
|
||||
else => @compileError(@typeName(T) ++ " is not a supported argument type!"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user