From e15a63ddb02276853d5264fd6f4b2cf2b85e834f Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Fri, 11 Oct 2024 14:29:28 -0400 Subject: [PATCH] Print out better information when an invalid number is given --- cmd/bulb/main.ha | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/bulb/main.ha b/cmd/bulb/main.ha index 0880dc5..84f8dd5 100644 --- a/cmd/bulb/main.ha +++ b/cmd/bulb/main.ha @@ -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; }; };