TW-1591: add and option to see non-pending project with command task summary

- Setting 'summary.all.projects' shows all projects, not just those with pending
  tasks.
This commit is contained in:
Paul Beckingham 2015-04-06 15:45:15 -04:00
parent 935b2993f3
commit 119c19b519
7 changed files with 22 additions and 7 deletions

View file

@ -248,3 +248,4 @@ suggestions:
Alexandre de Verteuil
Scott M
Stefan Frühwirth
Pierre Campet

View file

@ -25,6 +25,8 @@
Scott Carter).
- TW-1590 syntax of rcfile not documented (whitespace, line continuation)
(thanks to Scott M).
- TW-1591 add an option to see non-pending project with command task summary
(thanks to Pierre Campet).
- Setting 'bulk' to zero is interpreted as infinity, which means there is no
amount of changes that is considered dangerous (thanks to Tomas Babej).
- Disable hooks in bash completion script. Hooks were previously able to

2
NEWS
View file

@ -14,6 +14,8 @@ New configuration options in taskwarrior 2.4.3
amount of changes that is considered dangerous.
- The 'urgency.user.keyword.<keyword>.coefficient' setting allows tasks with
specific words in the description to have adjusted urgency.
- The 'summary.all.projects' setting shows all projects in the 'summary'
reportş instead of just those with pending tasks.
Newly deprecated features in taskwarrior 2.4.3

View file

@ -339,11 +339,16 @@ Default value is: 'You have more urgent tasks'.
It is a gentle reminder that you are contradicting your own urgency settings.
.TP
.B list.all.projects=yes
.B list.all.projects=no
May be yes or no, and determines whether the 'projects' command lists all the project
names you have used, or just the ones used in active tasks. The default value is
"no".
.TP
.B summary.all.projects=no
If set to yes, shows all projects in the summary report, even if there are no
pending tasks. The default value is "no".
.TP
.B complete.all.tags=yes
May be yes or no, and determines whether the tab completion scripts consider all

View file

@ -338,6 +338,7 @@ std::string Config::_defaults =
"_forcecolor=no # Forces color to be on, even for non TTY output\n"
"complete.all.tags=no # Include old tag names in '_ags' command\n"
"list.all.projects=no # Include old project names in 'projects' command\n"
"summary.all.projects=no # Include old project names in 'summary' command\n"
"list.all.tags=no # Include old tag names in 'tags' command\n"
"print.empty.columns=no # Print columns which have no data for any task\n"
"debug=no # Display diagnostics\n"

View file

@ -182,6 +182,7 @@ int CmdShow::execute (std::string& output)
" rule.precedence.color"
" search.case.sensitive"
" shell.prompt"
" summary.all.projects"
" tag.indicator"
" taskd.server"
" taskd.ca"

View file

@ -57,6 +57,7 @@ CmdSummary::CmdSummary ()
int CmdSummary::execute (std::string& output)
{
int rc = 0;
bool showAllProjects = context.config.getBoolean ("summary.all.projects");
// Apply filter.
handleRecurrence ();
@ -68,7 +69,7 @@ int CmdSummary::execute (std::string& output)
std::map <std::string, bool> allProjects;
std::vector <Task>::iterator task;
for (task = filtered.begin (); task != filtered.end (); ++task)
if (task->getStatus () == Task::pending)
if (showAllProjects || task->getStatus () == Task::pending)
allProjects[task->get ("project")] = false;
// Initialize counts, sum.
@ -122,7 +123,6 @@ int CmdSummary::execute (std::string& output)
}
}
// Create a table for output.
ViewText view;
view.width (context.getWidth ());
@ -143,7 +143,7 @@ int CmdSummary::execute (std::string& output)
std::map <std::string, bool>::iterator i;
for (i = allProjects.begin (); i != allProjects.end (); ++i)
{
if (countPending[i->first] > 0)
if (showAllProjects || countPending[i->first] > 0)
{
const std::vector <std::string> parents = extractParents (i->first);
std::vector <std::string>::const_iterator parent;
@ -169,7 +169,9 @@ int CmdSummary::execute (std::string& output)
int c = countCompleted[i->first];
int p = countPending[i->first];
int completedBar = (c * barWidth) / (c + p);
int completedBar = 0;
if (c + p)
completedBar = (c * barWidth) / (c + p);
std::string bar;
std::string subbar;
@ -185,7 +187,8 @@ int CmdSummary::execute (std::string& output)
}
view.set (row, 4, bar);
char percent[12];
char percent[12] = "0%";
if (c + p)
sprintf (percent, "%d%%", 100 * c / (c + p));
view.set (row, 3, percent);
processed.push_back (i->first);