CmdCustom: Generate notice about task news

This commit is contained in:
Tomas Babej 2021-10-02 16:58:16 -04:00
parent 5ccfece56d
commit ef53c4fc75
No known key found for this signature in database
GPG key ID: B0747C6578F7D2F5

View file

@ -26,6 +26,7 @@
#include <cmake.h>
#include <CmdCustom.h>
#include <random>
#include <sstream>
#include <map>
#include <vector>
@ -248,6 +249,29 @@ int CmdCustom::execute (std::string& output)
rc = 1;
}
// Inform user about the new release higlights if not presented yet
if (Context::getContext ().config.get ("news.version") != "2.6.0")
{
std::random_device device;
std::mt19937 random_generator(device());
std::uniform_int_distribution<std::mt19937::result_type> ten_percent(1, 10);
std::string NEWS_NOTICE = (
"Recently upgraded to 2.6.0. "
"Please run 'task news' to read higlights about the new release."
);
// 1 in 10 chance to display the message.
if (ten_percent(random_generator) == 10)
{
if (Context::getContext ().verbose ("footnote"))
Context::getContext ().footnote (NEWS_NOTICE);
else if (Context::getContext ().verbose ("header"))
Context::getContext ().header (NEWS_NOTICE);
}
}
feedback_backlog ();
output = out.str ();
return rc;