phonebook: exit with appropriate code.

This commit is contained in:
Kyle Isom 2023-10-21 19:58:22 -07:00
parent 168ee430f4
commit 9faed6a95b
1 changed files with 7 additions and 0 deletions

View File

@ -138,6 +138,7 @@ usage(ostream &os, int exc)
int
main(int argc, char *argv[])
{
int retc = 1;
bool help = false;
std::string fileName(pbFile);
@ -190,18 +191,24 @@ main(int argc, char *argv[])
switch (result) {
case Subcommand::Status::OK:
std::cout << "[+] OK\n";
retc = 0;
break;
case Subcommand::Status::NotEnoughArgs:
delete flags;
usage(cerr, 1);
break;
case Subcommand::Status::Failed:
cerr << "[!] '"<< command << "' failed\n";
break;
case Subcommand::Status::CommandNotRegistered:
delete flags;
cerr << "[!] '" << command << "' not registered.\n";
usage(cerr, 1);
break;
default:
delete flags;
abort();
}
return retc;
}