mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Enhanced export command
- Now sanitizes output by replacing ' with " in descriptions. - Added 'recur' attribute to exported output. - Removed recurring, deleted and complete tasks from the export.
This commit is contained in:
parent
8ac3978222
commit
5383943fa7
3 changed files with 24 additions and 5 deletions
|
@ -578,7 +578,7 @@ std::string handleDone (TDB& tdb, T& task, Config& conf)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string handleExport (TDB& tdb, T& task, Config& conf)
|
||||
{
|
||||
std::stringstream out;
|
||||
std::stringstream output;
|
||||
|
||||
// Use the description as a file name, then clobber the description so the
|
||||
// file name isn't used for filtering.
|
||||
|
@ -597,6 +597,7 @@ std::string handleExport (TDB& tdb, T& task, Config& conf)
|
|||
<< "'entry',"
|
||||
<< "'start',"
|
||||
<< "'due',"
|
||||
<< "'recur',"
|
||||
<< "'end',"
|
||||
<< "'project',"
|
||||
<< "'priority',"
|
||||
|
@ -605,14 +606,22 @@ std::string handleExport (TDB& tdb, T& task, Config& conf)
|
|||
<< "'description'"
|
||||
<< "\n";
|
||||
|
||||
int count = 0;
|
||||
std::vector <T> all;
|
||||
tdb.allT (all);
|
||||
tdb.allPendingT (all);
|
||||
filter (all, task);
|
||||
foreach (t, all)
|
||||
{
|
||||
out << t->composeCSV ().c_str ();
|
||||
if (t->getStatus () != T::recurring &&
|
||||
t->getStatus () != T::deleted)
|
||||
{
|
||||
out << t->composeCSV ().c_str ();
|
||||
++count;
|
||||
}
|
||||
}
|
||||
out.close ();
|
||||
|
||||
output << count << " tasks exported to '" << file << "'" << std::endl;
|
||||
}
|
||||
else
|
||||
throw std::string ("Could not write to export file.");
|
||||
|
@ -620,7 +629,7 @@ std::string handleExport (TDB& tdb, T& task, Config& conf)
|
|||
else
|
||||
throw std::string ("You must specify a file to write to.");
|
||||
|
||||
return out.str ();
|
||||
return output.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue