From db7b2dd9fea5afac9aee882225c07a6538099f59 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 25 Mar 2009 02:05:50 -0400 Subject: [PATCH] File Import - Implemented scaffolding for new import command. --- ChangeLog | 2 + html/import.html | 91 ++++++++++++++++++++++++++++++++++++++++++++ html/task.html | 3 ++ src/Makefile.am | 2 +- src/Makefile.in | 5 ++- src/import.cpp | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ src/parse.cpp | 1 + src/task.cpp | 5 +++ src/task.h | 3 ++ 9 files changed, 207 insertions(+), 3 deletions(-) create mode 100644 html/import.html create mode 100644 src/import.cpp diff --git a/ChangeLog b/ChangeLog index c3d281d33..d0bb8b228 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,8 @@ frequency, a due date, and an optional until date. + When a recurring task is modified, all other instances of the recurring task are also modified. + + Task can now import tasks from a variety of data formats. See online + docs for full details. ------ old releases ------------------------------ diff --git a/html/import.html b/html/import.html new file mode 100644 index 000000000..aee543927 --- /dev/null +++ b/html/import.html @@ -0,0 +1,91 @@ + + + + Data Import + + + + + +
+ + + + + + +
+ + +
+
+
+
+

Data Import

+
+
+ +
+
+
+

+ Copyright 2006-2009, P. Beckingham. All rights reserved. +

+
+ +
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+ +
+ + + + + + + diff --git a/html/task.html b/html/task.html index 0c471c85e..8fdd6d773 100644 --- a/html/task.html +++ b/html/task.html @@ -58,6 +58,7 @@
  • Filters
  • Shadow Files
  • Custom Reports +
  • Data Import

    @@ -116,6 +117,8 @@ frequency, a due date, and an optional until date.

  • When a recurring task is modified, all other instances of the recurring task are also modified. +
  • Task can now import tasks from a variety of data formats. See online + docs for full details.

    diff --git a/src/Makefile.am b/src/Makefile.am index 8203dbb14..c164f7999 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,2 +1,2 @@ bin_PROGRAMS = task -task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp Timer.cpp color.cpp parse.cpp task.cpp command.cpp report.cpp util.cpp text.cpp rules.cpp Config.h Date.h T.h TDB.h Table.h Grid.h Timer.h color.h task.h +task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp Timer.cpp color.cpp parse.cpp task.cpp command.cpp report.cpp util.cpp text.cpp rules.cpp import.cpp Config.h Date.h T.h TDB.h Table.h Grid.h Timer.h color.h task.h diff --git a/src/Makefile.in b/src/Makefile.in index ae8c519e5..0cdac5fab 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -47,7 +47,7 @@ am_task_OBJECTS = Config.$(OBJEXT) Date.$(OBJEXT) T.$(OBJEXT) \ TDB.$(OBJEXT) Table.$(OBJEXT) Grid.$(OBJEXT) Timer.$(OBJEXT) \ color.$(OBJEXT) parse.$(OBJEXT) task.$(OBJEXT) \ command.$(OBJEXT) report.$(OBJEXT) util.$(OBJEXT) \ - text.$(OBJEXT) rules.$(OBJEXT) + text.$(OBJEXT) rules.$(OBJEXT) import.$(OBJEXT) task_OBJECTS = $(am_task_OBJECTS) task_LDADD = $(LDADD) DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@ @@ -155,7 +155,7 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp Timer.cpp color.cpp parse.cpp task.cpp command.cpp report.cpp util.cpp text.cpp rules.cpp Config.h Date.h T.h TDB.h Table.h Grid.h Timer.h color.h task.h +task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp Timer.cpp color.cpp parse.cpp task.cpp command.cpp report.cpp util.cpp text.cpp rules.cpp import.cpp Config.h Date.h T.h TDB.h Table.h Grid.h Timer.h color.h task.h all: all-am .SUFFIXES: @@ -231,6 +231,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Timer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/color.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/command.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/import.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/report.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rules.Po@am__quote@ diff --git a/src/import.cpp b/src/import.cpp new file mode 100644 index 000000000..50504c3c6 --- /dev/null +++ b/src/import.cpp @@ -0,0 +1,98 @@ +//////////////////////////////////////////////////////////////////////////////// +// task - a command line task list manager. +// +// Copyright 2006 - 2009, Paul Beckingham. +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free Software +// Foundation; either version 2 of the License, or (at your option) any later +// version. +// +// This program is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +// details. +// +// You should have received a copy of the GNU General Public License along with +// this program; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// +#include +#include +#include "task.h" + +//////////////////////////////////////////////////////////////////////////////// +std::string handleImport (TDB& tdb, T& task, Config& conf) +{ + std::stringstream out; + + // Use the description as a file name. + std::string file = trim (task.getDescription ()); + + if (file.length () > 0) + { + out << "Not yet implemented." << std::endl; + } + else + throw std::string ("You must specify a file to import."); + + return out.str (); +} + +//////////////////////////////////////////////////////////////////////////////// +// 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 + +//////////////////////////////////////////////////////////////////////////////// +void determineFileType () +{ +} + +//////////////////////////////////////////////////////////////////////////////// +void importTask_1_5 () +{ +} + +void importTask_1_6 () +{ +} + +void importTodoSh_2_0 () +{ +} + +void importSingleLine () +{ +} + +void importCSV () +{ +} + +//////////////////////////////////////////////////////////////////////////////// + diff --git a/src/parse.cpp b/src/parse.cpp index 4dacbc0d2..e372f2352 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -131,6 +131,7 @@ static const char* commands[] = "help", "history", "ghistory", + "import", "info", "next", "overdue", diff --git a/src/task.cpp b/src/task.cpp index ac3ed392b..4ccf29db3 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -172,6 +172,10 @@ static std::string shortUsage (Config& conf) table.addCell (row, 1, "task stats"); table.addCell (row, 2, "Shows task database statistics"); + row = table.addRow (); + table.addCell (row, 1, "task import"); + table.addCell (row, 2, "Imports tasks from a variety of formats"); + row = table.addRow (); table.addCell (row, 1, "task export"); table.addCell (row, 2, "Exports all tasks as a CSV file"); @@ -844,6 +848,7 @@ std::string runTaskCommand ( else if (command == "start") { cmdMod = true; out = handleStart (tdb, task, conf); } else if (command == "stop") { cmdMod = true; out = handleStop (tdb, task, conf); } else if (command == "undo") { cmdMod = true; out = handleUndo (tdb, task, conf); } + else if (command == "import") { cmdMod = true; out = handleImport (tdb, task, conf); } // Command that display IDs and therefore need TDB::gc first. diff --git a/src/task.h b/src/task.h index a2c2c75b7..788ae26ca 100644 --- a/src/task.h +++ b/src/task.h @@ -143,4 +143,7 @@ std::string expandPath (const std::string&); void initializeColorRules (Config&); void autoColorize (T&, Text::color&, Text::color&, Config&); +// import.cpp +std::string handleImport (TDB&, T&, Config&); + ////////////////////////////////////////////////////////////////////////////////