Autodetect number radix

This commit is contained in:
data-man 2020-11-15 07:11:56 +05:00 committed by Felix Queißner
parent a26c10b3ba
commit 53f2acade9
2 changed files with 4 additions and 2 deletions

View File

@ -206,9 +206,9 @@ fn convertArgumentValue(comptime T: type, textInput: []const u8) !T {
else
return true, // boolean options are always true
.Int => |int| return if (int.is_signed)
try std.fmt.parseInt(T, textInput, 10)
try std.fmt.parseInt(T, textInput, 0)
else
try std.fmt.parseUnsigned(T, textInput, 10),
try std.fmt.parseUnsigned(T, textInput, 0),
.Float => return try std.fmt.parseFloat(T, textInput),
.Enum => {
if (@hasDecl(T, "parse")) {

View File

@ -11,6 +11,8 @@ pub fn main() !void {
@"with-hexdump": bool = false,
@"intermix-source": bool = false,
numberOfBytes: ?i32 = null,
signed_number: ?i64 = null,
unsigned_number: ?u64 = null,
mode: enum { default, special, slow, fast } = .default,
// This declares short-hand options for single hyphen