mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-30 02:17:21 +02:00
Merge branch '1.4.3' of git@github.com:pbeckingham/task into 1.4.3
Conflicts: ChangeLog html/task.html src/task.cpp
This commit is contained in:
commit
ce42ae9622
35 changed files with 620 additions and 258 deletions
|
@ -1618,85 +1618,6 @@ std::string handleReportGHistory (TDB& tdb, T& task, Config& conf)
|
|||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// A summary of the command usage. Not useful to users, but used to display
|
||||
// usage statistics for feedback.
|
||||
//
|
||||
// 2006-12-04 19:59:43 "task list"
|
||||
//
|
||||
std::string handleReportUsage (const TDB& tdb, T& task, Config& conf)
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
if (conf.get ("command.logging") == "on")
|
||||
{
|
||||
std::map <std::string, int> usage;
|
||||
std::vector <std::string> all;
|
||||
tdb.logRead (all);
|
||||
for (unsigned int i = 0; i < all.size (); ++i)
|
||||
{
|
||||
// 0123456789012345678901
|
||||
// v 21
|
||||
// 2006-12-04 19:59:43 "task list"
|
||||
std::string command = all[i].substr (21, all[i].length () - 22);
|
||||
|
||||
// Parse as a command line.
|
||||
std::vector <std::string> args;
|
||||
split (args, command, " ");
|
||||
|
||||
try
|
||||
{
|
||||
T task;
|
||||
std::string commandName;
|
||||
parse (args, commandName, task, conf);
|
||||
|
||||
usage[commandName]++;
|
||||
}
|
||||
|
||||
// Deliberately ignore errors from parsing the command log, as there may
|
||||
// be commands from a prior version of task in there, which were
|
||||
// abbreviated, and are now ambiguous.
|
||||
catch (...) {}
|
||||
}
|
||||
|
||||
// Now render the table.
|
||||
Table table;
|
||||
table.addColumn ("Command");
|
||||
table.addColumn ("Frequency");
|
||||
|
||||
if (conf.get ("color", true))
|
||||
{
|
||||
table.setColumnUnderline (0);
|
||||
table.setColumnUnderline (1);
|
||||
}
|
||||
else
|
||||
table.setTableDashedUnderline ();
|
||||
|
||||
table.setColumnJustification (1, Table::right);
|
||||
table.sortOn (1, Table::descendingNumeric);
|
||||
table.setDateFormat (conf.get ("dateformat", "m/d/Y"));
|
||||
|
||||
foreach (i, usage)
|
||||
{
|
||||
int row = table.addRow ();
|
||||
table.addCell (row, 0, (i->first == "" ? "(modify)" : i->first));
|
||||
table.addCell (row, 1, i->second);
|
||||
}
|
||||
|
||||
if (table.rowCount ())
|
||||
out << optionalBlankLine (conf)
|
||||
<< table.render ()
|
||||
<< std::endl;
|
||||
else
|
||||
out << "No usage." << std::endl;
|
||||
}
|
||||
else
|
||||
out << "Command logging is not enabled, so no history has been kept."
|
||||
<< std::endl;
|
||||
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string renderMonths (
|
||||
int firstMonth,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue