Autodetect number radix
This commit is contained in:
parent
a26c10b3ba
commit
53f2acade9
4
args.zig
4
args.zig
|
@ -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")) {
|
||||
|
|
2
demo.zig
2
demo.zig
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user