pushmsg: Proper exit code on HTTP error, fix documentation.

This commit is contained in:
tastytea 2021-09-13 12:46:33 +02:00
parent 196652762f
commit 1850f7b112
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 5 additions and 4 deletions

View File

@ -39,7 +39,7 @@ void read_options(int argc, char *argv[])
("message", po::value<std::string>()->required(), "Message body.")
("priority", po::value<std::int16_t>(),
"Priority of the message. Default is 5. "
"0 = no notification, 1-3 = silent, 4-7 = sound, 8-10 = popup.");
"0 = hidden notification, 1-3 = silent, 4-7 = sound, 8-10 = popup.");
// clang-format on
po::variables_map vm;
@ -89,11 +89,13 @@ int main(int argc, char *argv[])
{"priority", message.priority}};
const auto response{
conn.post("/message?token=" + message.token, json.dump())};
RestClient::disable();
switch (response.code)
{
case 200:
{
return 0;
break;
}
case 400:
@ -127,12 +129,11 @@ int main(int argc, char *argv[])
break;
}
}
RestClient::disable();
}
catch (const std::exception &e)
{
cerr << e.what() << '\n';
return 1;
}
return 1;
}