help: print byte slice defaults as strings
There are a couple of other places where []u8 is treated implicitly like a string, which isn't strictly correct. Ultimately, some kind of metasignal will be required to make this type truly unambiguous in interpretation.
This commit is contained in:
parent
adf05ca489
commit
86342bcd1f
@ -471,7 +471,17 @@ pub fn opt_info(comptime command: anytype) CommandHelp {
|
|||||||
// TODO: this is only acceptable for some types. It behaves poorly on
|
// TODO: this is only acceptable for some types. It behaves poorly on
|
||||||
// enum-based choice types because it prints the whole type name rather
|
// enum-based choice types because it prints the whole type name rather
|
||||||
// than just the tag name. Roll our own eventually.
|
// than just the tag name. Roll our own eventually.
|
||||||
|
blk: {
|
||||||
|
switch (@typeInfo(@TypeOf(def))) {
|
||||||
|
.Pointer => |info| if (info.size == .Slice and info.child == u8) {
|
||||||
|
writer.print("{s}", .{def}) catch @compileError("no");
|
||||||
|
break :blk;
|
||||||
|
},
|
||||||
|
else => {},
|
||||||
|
}
|
||||||
writer.print("{any}", .{def}) catch @compileError("whoah");
|
writer.print("{any}", .{def}) catch @compileError("whoah");
|
||||||
|
}
|
||||||
|
|
||||||
last_option.default = buf.buffer;
|
last_option.default = buf.buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user