mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CmdNews: Replace prompt at the beginning by defaulting to major items only
This commit is contained in:
parent
703594931a
commit
333840062b
1 changed files with 21 additions and 23 deletions
|
@ -497,35 +497,33 @@ int CmdNews::execute (std::string& output)
|
||||||
std::vector<NewsItem> items;
|
std::vector<NewsItem> items;
|
||||||
version2_6_0 (items);
|
version2_6_0 (items);
|
||||||
|
|
||||||
// Determine whether to use full or short summary
|
bool full_summary = false;
|
||||||
std::vector <std::string> options {"full", "short"};
|
bool major_items = true;
|
||||||
std::vector <std::string> matches;
|
|
||||||
|
for (auto word: words)
|
||||||
|
{
|
||||||
|
if (word == "major") {
|
||||||
|
major_items = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (word == "minor") {
|
||||||
|
major_items = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (word == "all") {
|
||||||
|
full_summary = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
signal (SIGINT, signal_handler);
|
signal (SIGINT, signal_handler);
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
std::cout << format (
|
|
||||||
"Do you want to see full summary ({1} feature(s)) or a short one ({2} feature(s))? (full/short) ",
|
|
||||||
items.size (),
|
|
||||||
std::count_if (items.begin (), items.end (), [](const NewsItem& n){return n._major;})
|
|
||||||
);
|
|
||||||
|
|
||||||
std::string answer;
|
|
||||||
std::getline (std::cin, answer);
|
|
||||||
answer = std::cin.eof () ? "full" : lowerCase (trim (answer));
|
|
||||||
|
|
||||||
autoComplete (answer, options, matches, 1); // Hard-coded 1.
|
|
||||||
}
|
|
||||||
while (! std::cin.eof () && matches.size () != 1);
|
|
||||||
|
|
||||||
signal (SIGINT, SIG_DFL);
|
|
||||||
bool full_summary = matches.size () == 1 && matches[0] == "full" ? true : false;
|
|
||||||
|
|
||||||
// Remove non-major items if displaying a non-full (abbreviated) summary
|
// Remove non-major items if displaying a non-full (abbreviated) summary
|
||||||
if (! full_summary)
|
if (! full_summary)
|
||||||
items.erase (
|
items.erase (
|
||||||
std::remove_if (items.begin (), items.end (), [](const NewsItem& n){return n._major == false;}),
|
std::remove_if (items.begin (), items.end (), [&](const NewsItem& n){return n._major != major_items;}),
|
||||||
items.end ()
|
items.end ()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue