builder: implement float options

This commit is contained in:
Vincent Rischmann 2020-12-19 16:26:23 +01:00 committed by Veikka Tuominen
parent b090451646
commit dd7b816d98

View File

@ -509,7 +509,26 @@ pub const Builder = struct {
return null;
},
},
.Float => panic("TODO float options to build script", .{}),
.Float => switch (entry.value.value) {
.Flag => {
warn("Expected -D{} to be a float, but received a boolean.\n", .{name});
self.markInvalidUserInput();
return null;
},
.Scalar => |s| {
const n = std.fmt.parseFloat(T, s) catch |err| {
warn("Expected -D{} to be a float of type {}.\n", .{ name, @typeName(T) });
self.markInvalidUserInput();
return null;
};
return n;
},
.List => {
warn("Expected -D{} to be a float, but received a list.\n", .{name});
self.markInvalidUserInput();
return null;
},
},
.Enum => switch (entry.value.value) {
.Flag => {
warn("Expected -D{} to be a string, but received a boolean.\n", .{name});