File Import

- Updated documentation.
- Added another recognized format - task command line.
This commit is contained in:
Paul Beckingham
2009-03-26 00:52:51 -04:00
parent 99dc72f26f
commit e4f5d6579c
3 changed files with 29 additions and 32 deletions

View File

@@ -20,8 +20,10 @@
frequency, a due date, and an optional until date. frequency, a due date, and an optional until date.
+ When a recurring task is modified, all other instances of the recurring + When a recurring task is modified, all other instances of the recurring
task are also modified. task are also modified.
+ Task can now import tasks from a variety of data formats. See online + Task can now import tasks from a variety of data formats, including task
docs for full details. export files from versions 1.4.3 and earlier, versions 1.5.0 and later,
todo.sh 2.x, CSV, plain text and task command line. See online docs for
full details.
------ old releases ------------------------------ ------ old releases ------------------------------

View File

@@ -117,8 +117,10 @@
frequency, a due date, and an optional until date. frequency, a due date, and an optional until date.
<li>When a recurring task is modified, all other instances of the recurring <li>When a recurring task is modified, all other instances of the recurring
task are also modified. task are also modified.
<li>Task can now import tasks from a variety of data formats. See online <li>Task can now import tasks from a variety of data formats, including task
docs for full details. export files from versions 1.4.3 and earlier, versions 1.5.0 and later,
todo.sh 2.x, CSV, plain text and task command line. See online docs for
full details.
</ul> </ul>
<p> <p>

View File

@@ -28,34 +28,13 @@
#include <sstream> #include <sstream>
#include "task.h" #include "task.h"
////////////////////////////////////////////////////////////////////////////////
// todo.sh v2.x
// file format: (A) Walk the dog +project @context
// x 2009-03-25 Walk the dog +project @context
// priority: (A) - (Z)
// multiple projects: +project
// multiple contexts: @context
// task >= 1.5 export
// file format: id,uuid,status,tags,entry,start,due,recur,end,project,
// priority,fg,bg,description\n
// task < 1.5 export
// file format: id,uuid,status,tags,entry,start,due,project,priority,
// fg,bg,description\n
// single line text
// file format: foo bar baz
// CSV
// file format: project,priority,description
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
enum fileType enum fileType
{ {
not_a_clue, not_a_clue,
task_1_4_3, task_1_4_3,
task_1_5_0, task_1_5_0,
task_cmd_line,
todo_sh_2_0, todo_sh_2_0,
csv, csv,
text text
@@ -85,6 +64,8 @@ static fileType determineFileType (const std::vector <std::string>& lines)
return task_1_4_3; return task_1_4_3;
} }
// TODO task_cmd_line
// x 2009-03-25 Walk the dog +project @context // x 2009-03-25 Walk the dog +project @context
// This is a test +project @context // This is a test +project @context
for (unsigned int i = 0; i < lines.size (); ++i) for (unsigned int i = 0; i < lines.size (); ++i)
@@ -125,7 +106,7 @@ static fileType determineFileType (const std::vector <std::string>& lines)
} }
} }
// CSV - commas on every line. // CSV - commas on every non-comment, non-trivial line.
bool commas_on_every_line = true; bool commas_on_every_line = true;
for (unsigned int i = 0; i < lines.size (); ++i) for (unsigned int i = 0; i < lines.size (); ++i)
{ {
@@ -177,6 +158,15 @@ static std::string importTask_1_5_0 (
return "task 1.5.0\n"; return "task 1.5.0\n";
} }
////////////////////////////////////////////////////////////////////////////////
static std::string importTaskCmdLine (
TDB& tdb,
Config& conf,
const std::vector <std::string>& lines)
{
return "task command line\n";
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static std::string importTodoSh_2_0 ( static std::string importTodoSh_2_0 (
TDB& tdb, TDB& tdb,
@@ -232,6 +222,8 @@ static std::string importCSV (
Config& conf, Config& conf,
const std::vector <std::string>& lines) const std::vector <std::string>& lines)
{ {
// TODO Allow any number of fields, but attempt to map into task fields.
// TODO Must have header line to name fields.
return "CSV\n"; return "CSV\n";
} }
@@ -251,11 +243,12 @@ std::string handleImport (TDB& tdb, T& task, Config& conf)
// Determine which type it might be, then attempt an import. // Determine which type it might be, then attempt an import.
switch (determineFileType (lines)) switch (determineFileType (lines))
{ {
case task_1_4_3: out << importTask_1_4_3 (tdb, conf, lines); break; case task_1_4_3: out << importTask_1_4_3 (tdb, conf, lines); break;
case task_1_5_0: out << importTask_1_5_0 (tdb, conf, lines); break; case task_1_5_0: out << importTask_1_5_0 (tdb, conf, lines); break;
case todo_sh_2_0: out << importTodoSh_2_0 (tdb, conf, lines); break; case task_cmd_line: out << importTaskCmdLine (tdb, conf, lines); break;
case csv: out << importCSV (tdb, conf, lines); break; case todo_sh_2_0: out << importTodoSh_2_0 (tdb, conf, lines); break;
case text: out << importText (tdb, conf, lines); break; case csv: out << importCSV (tdb, conf, lines); break;
case text: out << importText (tdb, conf, lines); break;
case not_a_clue: case not_a_clue:
out << "?"; out << "?";