From ef53c4fc7597fdb0cc1690fbdf2deb12a314aec4 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sat, 2 Oct 2021 16:58:16 -0400 Subject: [PATCH] CmdCustom: Generate notice about task news --- src/commands/CmdCustom.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/commands/CmdCustom.cpp b/src/commands/CmdCustom.cpp index 9e2e87b60..aa98ac58a 100644 --- a/src/commands/CmdCustom.cpp +++ b/src/commands/CmdCustom.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -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 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;