From 37b48c56d51c2175ef4b44bd9fc2436b6bdf1732 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 30 May 2011 11:42:35 -0400 Subject: [PATCH] Commands - export - The default export format is now JSON, with an alias that maps 'export' to '_query'. --- ChangeLog | 1 + NEWS | 2 + src/CMakeLists.txt | 1 - src/Cmd.cpp | 6 -- src/Config.cpp | 2 +- src/Context.cpp | 3 - src/export.cpp | 239 --------------------------------------------- src/main.h | 5 - 8 files changed, 4 insertions(+), 255 deletions(-) delete mode 100644 src/export.cpp diff --git a/ChangeLog b/ChangeLog index ff0355136..8fcf94f05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,7 @@ + The 'verbose' configuration variable now accepts a specific list of items to be verbose about. See taskrc(5). + New 'execute' command that runs external programs. + + The default export format is now JSON. # Tracked Features, sorted by ID. + Added feature #330, which supports the 'inverse' color attribute. diff --git a/NEWS b/NEWS index 767d94350..918bcd13c 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,7 @@ New Features in taskwarrior 2.0.0 - New 'next' report, that gauges urgency and reports the most urgent tasks. - Fine control of verbosity through the 'verbose=' configuration variable. - New 'execute' command that runs external scripts/programs. + - JSON is the new default export format. Please refer to the ChangeLog file for full details. There are too many to list here. @@ -39,6 +40,7 @@ New configuration options in taskwarrior 2.0.0 - New 'indent.annotation' for the description.default field format. - New 'color.label' for report column labels. - New 'verbose=...' support for individual verbosity settings. + - New 'avoidlastcolumn' support for Cygwin users. Newly deprecated features in taskwarrior 2.0.0 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 997174924..452b00acd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,7 +42,6 @@ set (task_SRCS API.cpp API.h ViewText.cpp ViewText.h command.cpp dependency.cpp - export.cpp feedback.cpp i18n.h import.cpp diff --git a/src/Cmd.cpp b/src/Cmd.cpp index a6950d362..461346beb 100644 --- a/src/Cmd.cpp +++ b/src/Cmd.cpp @@ -130,9 +130,6 @@ void Cmd::load () if (commands.size () == 0) { commands.push_back ("_query"); - commands.push_back ("export.csv"); - commands.push_back ("export.ical"); - commands.push_back ("export.yaml"); commands.push_back ("calendar"); commands.push_back ("delete"); commands.push_back ("done"); @@ -201,9 +198,6 @@ void Cmd::allCommands (std::vector & all) const bool Cmd::isReadOnlyCommand () { if (command == "_query" || - command == "export.csv" || - command == "export.ical" || - command == "export.yaml" || command == "calendar" || command == "push" || command == "summary" || diff --git a/src/Config.cpp b/src/Config.cpp index 2aad974a9..6df851c50 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -295,7 +295,7 @@ std::string Config::defaults = "alias.rm=delete # Alias for the delete command\n" "alias.history=history.monthly # Prefer monthly over annual history reports\n" "alias.ghistory=ghistory.monthly # Prefer monthly graphical over annual history reports\n" - "alias.export=export.yaml # Prefer YAML over CSV or iCal export\n" + "alias.export=_query # Prefer JSON as the prime format\n" "alias.export.vcalendar=export.ical # They are the same\n" "alias.export.json=_query # The _query command will be used for all export\n" "alias.burndown=burndown.weekly # Prefer the weekly burndown chart\n" diff --git a/src/Context.cpp b/src/Context.cpp index 6e03ddd0f..2d90c45b8 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -252,9 +252,6 @@ int Context::dispatch (std::string &out) else if (cmd.command == "timesheet") { rc = handleReportTimesheet (out); } else if (cmd.command == "done") { rc = handleDone (out); } else if (cmd.command == "delete") { rc = handleDelete (out); } - else if (cmd.command == "export.csv") { rc = handleExportCSV (out); } - else if (cmd.command == "export.ical") { rc = handleExportiCal (out); } - else if (cmd.command == "export.yaml") { rc = handleExportYAML (out); } else if (cmd.command == "import") { rc = handleImport (out); } else if (cmd.command == "duplicate") { rc = handleDuplicate (out); } else if (cmd.command == "undo") { handleUndo ( ); } diff --git a/src/export.cpp b/src/export.cpp deleted file mode 100644 index be3cc8f39..000000000 --- a/src/export.cpp +++ /dev/null @@ -1,239 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// taskwarrior - a command line task list manager. -// -// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez. -// 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 - -#include -#include -#include -#include -#include - -extern Context context; - -//////////////////////////////////////////////////////////////////////////////// -int handleExportCSV (std::string& outs) -{ - int rc = 0; - std::stringstream out; - - // Deliberately no 'id'. - out << "'uuid'," - << "'status'," - << "'tags'," - << "'entry'," - << "'start'," - << "'due'," - << "'recur'," - << "'end'," - << "'project'," - << "'priority'," - << "'fg'," - << "'bg'," - << "'description'" - << "\n"; - - // Get all the tasks. - std::vector tasks; - context.tdb.lock (context.config.getBoolean ("locking")); - handleRecurrence (); - context.tdb.load (tasks, context.filter); - context.tdb.commit (); - context.tdb.unlock (); - - foreach (task, tasks) - if (task->getStatus () != Task::recurring) - out << task->composeCSV ().c_str (); - - outs = out.str (); - - // Prevent messages from cluttering the export output. - context.headers.clear (); - return rc; -} - -//////////////////////////////////////////////////////////////////////////////// -// http://tools.ietf.org/html/rfc5545 -// -// Note: Recurring tasks could be included in more detail. -int handleExportiCal (std::string& outs) -{ - int rc = 0; - std::stringstream out; - - out << "BEGIN:VCALENDAR\n" - << "VERSION:2.0\n" - << "PRODID:-//GBF//" << PACKAGE_STRING << "//EN\n"; - - // Get all the tasks. - std::vector tasks; - context.tdb.lock (context.config.getBoolean ("locking")); - handleRecurrence (); - context.tdb.load (tasks, context.filter); - context.tdb.commit (); - context.tdb.unlock (); - - foreach (task, tasks) - { - if (task->getStatus () != Task::recurring) - { - out << "BEGIN:VTODO\n"; - - // Required UID:20070313T123432Z-456553@example.com - out << "UID:" << task->get ("uuid") << "\n"; - - // Required DTSTAMP:20070313T123432Z - Date entry (atoi (task->get ("entry").c_str ())); - out << "DTSTAMP:" << entry.toISO () << "\n"; - - // Optional DTSTART:20070514T110000Z - if (task->has ("start")) - { - Date start (atoi (task->get ("start").c_str ())); - out << "DTSTART:" << start.toISO () << "\n"; - } - - // Optional DUE:20070709T130000Z - if (task->has ("due")) - { - Date due (atoi (task->get ("due").c_str ())); - out << "DUE:" << due.toISO () << "\n"; - } - - // Optional COMPLETED:20070707T100000Z - if (task->has ("end") && task->getStatus () == Task::completed) - { - Date end (atoi (task->get ("end").c_str ())); - out << "COMPLETED:" << end.toISO () << "\n"; - } - - out << "SUMMARY:" << task->get ("description") << "\n"; - - // Optional CLASS:PUBLIC/PRIVATE/CONFIDENTIAL - std::string classification = context.config.get ("export.ical.class"); - if (classification == "") - classification = "PRIVATE"; - out << "CLASS:" << classification << "\n"; - - // Optional multiple CATEGORIES:FAMILY,FINANCE - if (task->getTagCount () > 0) - { - std::vector tags; - task->getTags (tags); - std::string all; - join (all, ",", tags); - out << "CATEGORIES:" << all << "\n"; - } - - // Optional PRIORITY: - // 1-4 H - // 5 M - // 6-9 L - if (task->has ("priority")) - { - out << "PRIORITY:"; - std::string priority = task->get ("priority"); - - if (priority == "H") out << "1"; - else if (priority == "M") out << "5"; - else out << "9"; - - out << "\n"; - } - - // Optional STATUS:NEEDS-ACTION/IN-PROCESS/COMPLETED/CANCELLED - out << "STATUS:"; - Task::status stat = task->getStatus (); - if (stat == Task::pending || stat == Task::waiting) - { - if (task->has ("start")) - out << "IN-PROCESS"; - else - out << "NEEDS-ACTION"; - } - else if (stat == Task::completed) - { - out << "COMPLETED"; - } - else if (stat == Task::deleted) - { - out << "CANCELLED"; - } - out << "\n"; - - // Optional COMMENT:annotation1 - // Optional COMMENT:annotation2 - std::vector annotations; - task->getAnnotations (annotations); - foreach (anno, annotations) - out << "COMMENT:" << anno->value () << "\n"; - - out << "END:VTODO\n"; - } - } - - out << "END:VCALENDAR\n"; - - outs = out.str (); - - // Prevent messages from cluttering the export output. - context.headers.clear (); - return rc; -} - -//////////////////////////////////////////////////////////////////////////////// -int handleExportYAML (std::string& outs) -{ - int rc = 0; - - // YAML header. - std::stringstream out; - out << "%YAML 1.1\n" - << "---\n"; - - // Get all the tasks. - std::vector tasks; - context.tdb.lock (context.config.getBoolean ("locking")); - handleRecurrence (); - context.tdb.load (tasks, context.filter); - context.tdb.commit (); - context.tdb.unlock (); - - foreach (task, tasks) - out << task->composeYAML ().c_str (); - - out << "...\n"; - outs = out.str (); - - // Prevent messages from cluttering the export output. - context.headers.clear (); - return rc; -} - -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/main.h b/src/main.h index 822ee5314..5e0bd906c 100644 --- a/src/main.h +++ b/src/main.h @@ -90,11 +90,6 @@ std::string colorizeDebug (const std::string&); // import.cpp int handleImport (std::string&); -// export.cpp -int handleExportCSV (std::string&); -int handleExportiCal (std::string&); -int handleExportYAML (std::string&); - // dependency.cpp bool dependencyIsBlocked (const Task&); void dependencyGetBlocked (const Task&, std::vector &);