Print out better information when an invalid number is given

This commit is contained in:
Sasha Koshka 2024-10-11 14:29:28 -04:00
parent dddb8648f4
commit e15a63ddb0

View File

@ -43,7 +43,8 @@ export fn main() void = {
case let num: int =>
number = num;
case =>
getopt::printhelp(os::stdout, name, cmd.help)!;
fmt::errorf("{}: option -{} requires a number\n", name, opt.0)!;
getopt::printusage(os::stdout, name, cmd.help)!;
os::exit(os::status::FAILURE);
};
case 'p' =>
@ -58,7 +59,7 @@ export fn main() void = {
// list boards and exit
match (bulb::list(os::stdout)) {
case let err: bulb::error =>
fmt::errorf("{}: Could not list boards: {}\n", name, bulb::strerror(err))!;
fmt::errorf("{}: could not list boards: {}\n", name, bulb::strerror(err))!;
os::exit(os::status::FAILURE);
case void =>
os::exit(os::status::SUCCESS);
@ -70,7 +71,7 @@ export fn main() void = {
let user_name = if (anonymous) void else get_user_name();
match (bulb::post(os::stdin, board, user_name)) {
case let err: bulb::error =>
fmt::errorf("{}: Could not post to {}: {}\n", name, board, bulb::strerror(err))!;
fmt::errorf("{}: could not post to {}: {}\n", name, board, bulb::strerror(err))!;
case void => void;
};
};
@ -78,7 +79,7 @@ export fn main() void = {
// read latest posts on the board
match (bulb::read(os::stdout, board, number)) {
case let err: bulb::error =>
fmt::errorf("{}: Could not read {}: {}\n", name, board, bulb::strerror(err))!;
fmt::errorf("{}: could not read {}: {}\n", name, board, bulb::strerror(err))!;
case void => void;
};
};