mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
- Removed support for the "command.logging" configuration variable and
the "task usage" command.
This commit is contained in:
parent
78fae5195b
commit
d837a25be7
12 changed files with 6 additions and 171 deletions
|
@ -1,14 +1,10 @@
|
||||||
Version numbers are of the form:
|
|
||||||
|
|
||||||
X.Y.Z
|
|
||||||
|
|
||||||
where the X represents a major version number, or architecture. The Y
|
|
||||||
represents a feature release, and the Z represents a patch.
|
|
||||||
|
|
||||||
------ current release ---------------------------
|
------ current release ---------------------------
|
||||||
|
|
||||||
1.5.0 (?)
|
1.5.0 (?)
|
||||||
+ Removed deprecated TUTORIAL file.
|
+ Removed deprecated TUTORIAL file.
|
||||||
|
+ Removed "usage" command, and support for "command.logging" configuration
|
||||||
|
variable.
|
||||||
|
|
||||||
------ old releases ------------------------------
|
------ old releases ------------------------------
|
||||||
|
|
||||||
|
|
|
@ -313,19 +313,6 @@ ID Project Pri Description
|
||||||
This command displays all the colors that task supports.
|
This command displays all the colors that task supports.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<strong>% task usage</strong>
|
|
||||||
<p>
|
|
||||||
If logging has been enabled by the "command.logging=on" directive
|
|
||||||
in the .taskrc file, then task will record every command that is
|
|
||||||
run. When this command is run, task will display a count of how
|
|
||||||
many times each command was used.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
This command is for the purpose of seeing whether command are
|
|
||||||
actually used.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<strong>% task version</strong>
|
<strong>% task version</strong>
|
||||||
<p>
|
<p>
|
||||||
This can be used to show the version number of task, and to display
|
This can be used to show the version number of task, and to display
|
||||||
|
|
|
@ -51,13 +51,6 @@
|
||||||
/Users/paul/.task
|
/Users/paul/.task
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt>command.logging</dt>
|
|
||||||
<dd>
|
|
||||||
May be "on" or "off", defaulting to "off". This determines
|
|
||||||
whether task records commands. This is not generally useful,
|
|
||||||
except while developing task.
|
|
||||||
</dd>
|
|
||||||
|
|
||||||
<dt>confirmation</dt>
|
<dt>confirmation</dt>
|
||||||
<dd>
|
<dd>
|
||||||
May be "yes" or "no", and determines whether task will ask for
|
May be "yes" or "no", and determines whether task will ask for
|
||||||
|
|
|
@ -96,7 +96,9 @@
|
||||||
|
|
||||||
<h4>New in version 1.5.0 (?)</h4>
|
<h4>New in version 1.5.0 (?)</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>Removed deprecated TUTORIAL file.
|
||||||
|
<li>Removed "usage" command, and support for "command.logging" configuration
|
||||||
|
variable.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
task info ID
|
task info ID
|
||||||
task start ID
|
task start ID
|
||||||
task done ID
|
task done ID
|
||||||
|
task undo ID
|
||||||
task projects
|
task projects
|
||||||
task tags
|
task tags
|
||||||
task summary
|
task summary
|
||||||
|
@ -57,7 +58,6 @@
|
||||||
task oldest
|
task oldest
|
||||||
task newest
|
task newest
|
||||||
task stats
|
task stats
|
||||||
task usage
|
|
||||||
task export
|
task export
|
||||||
task color
|
task color
|
||||||
task version
|
task version
|
||||||
|
|
|
@ -112,7 +112,6 @@ void Config::createDefault (const std::string& home)
|
||||||
if ((out = fopen (rcFile.c_str (), "w")))
|
if ((out = fopen (rcFile.c_str (), "w")))
|
||||||
{
|
{
|
||||||
fprintf (out, "data.location=%s\n", dataDir.c_str ());
|
fprintf (out, "data.location=%s\n", dataDir.c_str ());
|
||||||
fprintf (out, "command.logging=off\n");
|
|
||||||
fprintf (out, "confirmation=yes\n");
|
fprintf (out, "confirmation=yes\n");
|
||||||
fprintf (out, "next=2\n");
|
fprintf (out, "next=2\n");
|
||||||
fprintf (out, "dateformat=m/d/Y\n");
|
fprintf (out, "dateformat=m/d/Y\n");
|
||||||
|
|
54
src/TDB.cpp
54
src/TDB.cpp
|
@ -37,7 +37,6 @@
|
||||||
TDB::TDB ()
|
TDB::TDB ()
|
||||||
: mPendingFile ("")
|
: mPendingFile ("")
|
||||||
, mCompletedFile ("")
|
, mCompletedFile ("")
|
||||||
, mLogFile ("")
|
|
||||||
, mId (1)
|
, mId (1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -54,7 +53,6 @@ void TDB::dataDirectory (const std::string& directory)
|
||||||
{
|
{
|
||||||
mPendingFile = directory + "/pending.data";
|
mPendingFile = directory + "/pending.data";
|
||||||
mCompletedFile = directory + "/completed.data";
|
mCompletedFile = directory + "/completed.data";
|
||||||
mLogFile = directory + "/command.log";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -286,58 +284,6 @@ bool TDB::modifyT (const T& t)
|
||||||
return overwritePending (pending);
|
return overwritePending (pending);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool TDB::logRead (std::vector <std::string>& entries) const
|
|
||||||
{
|
|
||||||
entries.clear ();
|
|
||||||
return readLockedFile (mLogFile, entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool TDB::logCommand (int argc, char** argv) const
|
|
||||||
{
|
|
||||||
// Get time info.
|
|
||||||
time_t now;
|
|
||||||
time (&now);
|
|
||||||
struct tm* t = localtime (&now);
|
|
||||||
|
|
||||||
// Generate timestamp.
|
|
||||||
char timestamp[20];
|
|
||||||
sprintf (timestamp, "%04d-%02d-%02d %02d:%02d:%02d",
|
|
||||||
t->tm_year + 1900,
|
|
||||||
t->tm_mon + 1,
|
|
||||||
t->tm_mday,
|
|
||||||
t->tm_hour,
|
|
||||||
t->tm_min,
|
|
||||||
t->tm_sec);
|
|
||||||
|
|
||||||
std::string command = timestamp;
|
|
||||||
command += " \"";
|
|
||||||
for (int i = 0; i < argc; ++i)
|
|
||||||
command += std::string (i ? " " : "") + argv[i];
|
|
||||||
command += "\"\n";
|
|
||||||
|
|
||||||
if (! access (mLogFile.c_str (), F_OK | W_OK))
|
|
||||||
{
|
|
||||||
FILE* out;
|
|
||||||
if ((out = fopen (mLogFile.c_str (), "a")))
|
|
||||||
{
|
|
||||||
#ifdef HAVE_FLOCK
|
|
||||||
int retry = 0;
|
|
||||||
while (flock (fileno (out), LOCK_EX) && ++retry <= 3)
|
|
||||||
delay (0.25);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fputs (command.c_str (), out);
|
|
||||||
|
|
||||||
fclose (out);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool TDB::lock (FILE* file) const
|
bool TDB::lock (FILE* file) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,7 +48,6 @@ public:
|
||||||
bool addT (const T&) const;
|
bool addT (const T&) const;
|
||||||
bool modifyT (const T&);
|
bool modifyT (const T&);
|
||||||
bool logRead (std::vector <std::string>&) const;
|
bool logRead (std::vector <std::string>&) const;
|
||||||
bool logCommand (int, char**) const;
|
|
||||||
int gc ();
|
int gc ();
|
||||||
int nextId ();
|
int nextId ();
|
||||||
|
|
||||||
|
@ -62,7 +61,6 @@ private:
|
||||||
private:
|
private:
|
||||||
std::string mPendingFile;
|
std::string mPendingFile;
|
||||||
std::string mCompletedFile;
|
std::string mCompletedFile;
|
||||||
std::string mLogFile;
|
|
||||||
int mId;
|
int mId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,6 @@ static const char* commands[] =
|
||||||
"tags",
|
"tags",
|
||||||
"undelete",
|
"undelete",
|
||||||
"undo",
|
"undo",
|
||||||
"usage",
|
|
||||||
"version",
|
"version",
|
||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
|
@ -1594,81 +1594,6 @@ void handleReportGHistory (TDB& tdb, T& task, Config& conf)
|
||||||
std::cout << "No tasks." << std::endl;
|
std::cout << "No tasks." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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"
|
|
||||||
//
|
|
||||||
void handleReportUsage (const TDB& tdb, T& task, Config& conf)
|
|
||||||
{
|
|
||||||
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 ())
|
|
||||||
std::cout << optionalBlankLine (conf)
|
|
||||||
<< table.render ()
|
|
||||||
<< std::endl;
|
|
||||||
else
|
|
||||||
std::cout << "No usage." << std::endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
std::cout << "Command logging is not enabled, so no history has been kept."
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string renderMonths (
|
std::string renderMonths (
|
||||||
int firstMonth,
|
int firstMonth,
|
||||||
|
|
|
@ -178,10 +178,6 @@ static void shortUsage (Config& conf)
|
||||||
table.addCell (row, 1, "task stats");
|
table.addCell (row, 1, "task stats");
|
||||||
table.addCell (row, 2, "Shows task database statistics");
|
table.addCell (row, 2, "Shows task database statistics");
|
||||||
|
|
||||||
row = table.addRow ();
|
|
||||||
table.addCell (row, 1, "task usage");
|
|
||||||
table.addCell (row, 2, "Shows task command usage frequency");
|
|
||||||
|
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 1, "task export");
|
table.addCell (row, 1, "task export");
|
||||||
table.addCell (row, 2, "Exports all tasks as a CSV file");
|
table.addCell (row, 2, "Exports all tasks as a CSV file");
|
||||||
|
@ -296,10 +292,6 @@ int main (int argc, char** argv)
|
||||||
TDB tdb;
|
TDB tdb;
|
||||||
tdb.dataDirectory (expandPath (conf.get ("data.location")));
|
tdb.dataDirectory (expandPath (conf.get ("data.location")));
|
||||||
|
|
||||||
// Log commands, if desired.
|
|
||||||
if (conf.get ("command.logging") == "on")
|
|
||||||
tdb.logCommand (argc, argv);
|
|
||||||
|
|
||||||
// If argc == 1 and the default.command configuration variable is set,
|
// If argc == 1 and the default.command configuration variable is set,
|
||||||
// then use that, otherwise stick with argc/argv.
|
// then use that, otherwise stick with argc/argv.
|
||||||
std::vector <std::string> args;
|
std::vector <std::string> args;
|
||||||
|
@ -347,7 +339,6 @@ int main (int argc, char** argv)
|
||||||
else if (command == "oldest") handleReportOldest (tdb, task, conf);
|
else if (command == "oldest") handleReportOldest (tdb, task, conf);
|
||||||
else if (command == "newest") handleReportNewest (tdb, task, conf);
|
else if (command == "newest") handleReportNewest (tdb, task, conf);
|
||||||
else if (command == "stats") handleReportStats (tdb, task, conf);
|
else if (command == "stats") handleReportStats (tdb, task, conf);
|
||||||
else if (command == "usage") handleReportUsage (tdb, task, conf);
|
|
||||||
else if (command == "" && task.getId ()) handleModify (tdb, task, conf);
|
else if (command == "" && task.getId ()) handleModify (tdb, task, conf);
|
||||||
else if (command == "help") longUsage (conf);
|
else if (command == "help") longUsage (conf);
|
||||||
else shortUsage (conf);
|
else shortUsage (conf);
|
||||||
|
|
|
@ -92,7 +92,6 @@ void handleReportSummary (TDB&, T&, Config&);
|
||||||
void handleReportNext (TDB&, T&, Config&);
|
void handleReportNext (TDB&, T&, Config&);
|
||||||
void handleReportHistory (TDB&, T&, Config&);
|
void handleReportHistory (TDB&, T&, Config&);
|
||||||
void handleReportGHistory (TDB&, T&, Config&);
|
void handleReportGHistory (TDB&, T&, Config&);
|
||||||
void handleReportUsage (const TDB&, T&, Config&);
|
|
||||||
void handleReportCalendar (TDB&, T&, Config&);
|
void handleReportCalendar (TDB&, T&, Config&);
|
||||||
void handleReportActive (TDB&, T&, Config&);
|
void handleReportActive (TDB&, T&, Config&);
|
||||||
void handleReportOverdue (TDB&, T&, Config&);
|
void handleReportOverdue (TDB&, T&, Config&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue