parser: actually print failure message upon failure

There is still much work to do on this front.
This commit is contained in:
torque 2023-04-04 23:20:29 -07:00
parent ab07222666
commit e09d542c3a
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk

View File

@ -432,9 +432,17 @@ pub fn Parser(comptime command: anytype, comptime callback: anytype) type {
const writer = buffer.writer();
if (comptime @TypeOf(param).has_output) {
@field(self.output, param.name) = try param.converter(context, intermediate, writer);
@field(self.output, param.name) = param.converter(context, intermediate, writer) catch |err| {
const stderr = std.io.getStdErr().writer();
stderr.print("Error parsing option \"{s}\": {s}\n", .{ param.name, buffer.items }) catch {};
return err;
};
} else {
try param.converter(context, intermediate, writer);
param.converter(context, intermediate, writer) catch |err| {
const stderr = std.io.getStdErr().writer();
stderr.print("Error parsing option \"{s}\": {s}\n", .{ param.name, buffer.items }) catch {};
return err;
};
}
} else {
if (comptime param.required) {