pushmsg: Proper exit code on HTTP error, fix documentation.
This commit is contained in:
parent
196652762f
commit
1850f7b112
@ -39,7 +39,7 @@ void read_options(int argc, char *argv[])
|
|||||||
("message", po::value<std::string>()->required(), "Message body.")
|
("message", po::value<std::string>()->required(), "Message body.")
|
||||||
("priority", po::value<std::int16_t>(),
|
("priority", po::value<std::int16_t>(),
|
||||||
"Priority of the message. Default is 5. "
|
"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
|
// clang-format on
|
||||||
|
|
||||||
po::variables_map vm;
|
po::variables_map vm;
|
||||||
@ -89,11 +89,13 @@ int main(int argc, char *argv[])
|
|||||||
{"priority", message.priority}};
|
{"priority", message.priority}};
|
||||||
const auto response{
|
const auto response{
|
||||||
conn.post("/message?token=" + message.token, json.dump())};
|
conn.post("/message?token=" + message.token, json.dump())};
|
||||||
|
RestClient::disable();
|
||||||
|
|
||||||
switch (response.code)
|
switch (response.code)
|
||||||
{
|
{
|
||||||
case 200:
|
case 200:
|
||||||
{
|
{
|
||||||
|
return 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 400:
|
case 400:
|
||||||
@ -127,12 +129,11 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RestClient::disable();
|
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
cerr << e.what() << '\n';
|
cerr << e.what() << '\n';
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user