File Import

- Implemented scaffolding for new import command.
This commit is contained in:
Paul Beckingham 2009-03-25 02:05:50 -04:00
parent c31ec6b6a6
commit db7b2dd9fe
9 changed files with 207 additions and 3 deletions

View file

@ -20,6 +20,8 @@
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
docs for full details.
------ old releases ------------------------------ ------ old releases ------------------------------

91
html/import.html Normal file
View file

@ -0,0 +1,91 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Data Import</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="task.css" type="text/css" />
</head>
<body>
<div id="container">
<table>
<tr>
<td>
<div id="toolbar">
<a href="task.html">Home</a>
<a href="setup.html">Setup</a>
<a href="30second.html">30-second Tutorial</a>
<a href="simple.html">Simple</a>
<a href="advanced.html">Advanced</a>
<a href="shell.html">Shell</a>
<a href="config.html">Configuration</a>
<a href="color.html">Colors</a>
<a href="usage.html">Usage</a>
<a href="recur.html">Recurrence</a>
<a href="date.html">Date Handling</a>
<a href="troubleshooting.html">Troubleshooting</a>
<a href="versions.html">Old Versions</a>
<a href="links.html">Task on the Web</a>
</div>
<div id="content">
<br />
<br />
<br />
<h2 class="title">Data Import</h2>
<div class="content">
</div>
<br />
<br />
<div class="content">
<p>
Copyright 2006-2009, P. Beckingham. All rights reserved.
</p>
</div>
</div>
</td>
<td align="right" valign="top" width="200px">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<script type="text/javascript"><!--
google_ad_client = "pub-9709799404235424";
/* Task Main */
google_ad_slot = "8660617875";
google_ad_width = 120;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4737637-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</body>
</html>

View file

@ -58,6 +58,7 @@
<li><a href="filter.html">Filters</a> <li><a href="filter.html">Filters</a>
<li><a href="shadow.html">Shadow Files</a> <li><a href="shadow.html">Shadow Files</a>
<li><a href="custom.html">Custom Reports</a> <li><a href="custom.html">Custom Reports</a>
<li><a href="import.html">Data Import</a>
</ul> </ul>
<p> <p>
@ -116,6 +117,8 @@
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
docs for full details.
</ul> </ul>
<p> <p>

View file

@ -1,2 +1,2 @@
bin_PROGRAMS = task 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

View file

@ -47,7 +47,7 @@ am_task_OBJECTS = Config.$(OBJEXT) Date.$(OBJEXT) T.$(OBJEXT) \
TDB.$(OBJEXT) Table.$(OBJEXT) Grid.$(OBJEXT) Timer.$(OBJEXT) \ TDB.$(OBJEXT) Table.$(OBJEXT) Grid.$(OBJEXT) Timer.$(OBJEXT) \
color.$(OBJEXT) parse.$(OBJEXT) task.$(OBJEXT) \ color.$(OBJEXT) parse.$(OBJEXT) task.$(OBJEXT) \
command.$(OBJEXT) report.$(OBJEXT) util.$(OBJEXT) \ command.$(OBJEXT) report.$(OBJEXT) util.$(OBJEXT) \
text.$(OBJEXT) rules.$(OBJEXT) text.$(OBJEXT) rules.$(OBJEXT) import.$(OBJEXT)
task_OBJECTS = $(am_task_OBJECTS) task_OBJECTS = $(am_task_OBJECTS)
task_LDADD = $(LDADD) task_LDADD = $(LDADD)
DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@ DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
@ -155,7 +155,7 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@ target_alias = @target_alias@
top_builddir = @top_builddir@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@ 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 all: all-am
.SUFFIXES: .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)/Timer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/color.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)/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)/parse.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/report.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@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rules.Po@am__quote@

98
src/import.cpp Normal file
View file

@ -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 <iostream>
#include <sstream>
#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 ()
{
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -131,6 +131,7 @@ static const char* commands[] =
"help", "help",
"history", "history",
"ghistory", "ghistory",
"import",
"info", "info",
"next", "next",
"overdue", "overdue",

View file

@ -172,6 +172,10 @@ static std::string 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 import");
table.addCell (row, 2, "Imports tasks from a variety of formats");
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");
@ -844,6 +848,7 @@ std::string runTaskCommand (
else if (command == "start") { cmdMod = true; out = handleStart (tdb, task, conf); } 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 == "stop") { cmdMod = true; out = handleStop (tdb, task, conf); }
else if (command == "undo") { cmdMod = true; out = handleUndo (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. // Command that display IDs and therefore need TDB::gc first.

View file

@ -143,4 +143,7 @@ std::string expandPath (const std::string&);
void initializeColorRules (Config&); void initializeColorRules (Config&);
void autoColorize (T&, Text::color&, Text::color&, Config&); void autoColorize (T&, Text::color&, Text::color&, Config&);
// import.cpp
std::string handleImport (TDB&, T&, Config&);
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////