diff --git a/NEWS b/NEWS index 81367f4df..7f6fb71cc 100644 --- a/NEWS +++ b/NEWS @@ -55,7 +55,9 @@ New configuration options in taskwarrior 1.9.4 Newly deprecated features in taskwarrior 1.9.4 - - + - The export commands (export, export.csv, export.yaml, export.ical and + export.vcalendar) are deprecated, and will be replaced in future releases + by add-on scripts. --- diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index e4e299354..e56ca036a 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -1 +1 @@ -install (DIRECTORY bash fish vim zsh DESTINATION share/doc/task/scripts) +install (DIRECTORY bash fish vim zsh add-ons DESTINATION share/doc/task/scripts) diff --git a/scripts/add-ons/export-csv.pl b/scripts/add-ons/export-csv.pl new file mode 100755 index 000000000..0083b41de --- /dev/null +++ b/scripts/add-ons/export-csv.pl @@ -0,0 +1,70 @@ +#! /usr/bin/perl +################################################################################ +## 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 +## +################################################################################ + +use strict; +use warnings; +use JSON; + +# Use the taskwarrior 1.9.4+ _query command to issue a query and return JSON +my $command = '/usr/local/bin/task _query ' . join (' ', @ARGV); + +# Generate output. +print "'uuid','status','tags','entry','start','due','recur','end','project',", + "'priority','fg','bg','description'\n"; + +for my $task (split /,$/ms, qx{$command}) +{ + my $data = from_json ($task); + + print "'$data->{'uuid'}',", + "'$data->{'status'}',", + "'", (exists $data->{'tags'} ? join (' ', @{$data->{'tags'}}) : ''), "',", + "'$data->{'entry'}',", + "'", ($data->{'start'} || ''), "',", + "'", ($data->{'due'} || ''), "',", + "'", ($data->{'recur'} || ''), "',", + "'", ($data->{'end'} || ''), "',", + "'", ($data->{'project'} || ''), "',", + "'", ($data->{'priority'} || ''), "',", + "'", ($data->{'fg'} || ''), "',", + "'", ($data->{'bg'} || ''), "',", + "'$data->{'description'}'", + "\n"; + + # Note that this format ignores: + # wait + # until + # annotations + # mask + # imask +} + +exit 0; + +################################################################################ + diff --git a/scripts/add-ons/export-ical.pl b/scripts/add-ons/export-ical.pl new file mode 100755 index 000000000..742736446 --- /dev/null +++ b/scripts/add-ons/export-ical.pl @@ -0,0 +1,91 @@ +#! /usr/bin/perl +################################################################################ +## 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 +## +################################################################################ + +use strict; +use warnings; +use JSON; + +# Use the taskwarrior 1.9.4+ _query command to issue a query and return JSON +my $command = '/usr/local/bin/task _query ' . join (' ', @ARGV); + +# Generate output. +print "BEGIN:VCALENDAR\n", + "VERSION:2.0\n", + "PRODID:=//GBF/taskwarrior 1.9.4//EN\n"; + +for my $task (split /,$/ms, qx{$command}) +{ + my $data = from_json ($task); + + print "BEGIN:VTODO\n"; + print "UID:$data->{'uuid'}\n"; + print "DTSTAMP:$data->{'entry'}\n"; + print "DTSTART:$data->{'start'}\n" if exists $data->{'start'}; + print "DUE:$data->{'due'}\n" if exists $data->{'due'}; + print "COMPLETED:$data->{'end'}\n" if exists $data->{'end'}; + print "SUMMARY:$data->{'description'}\n"; + print "CLASS:PRIVATE\n"; + print "CATEGORIES:", join (',', @{$data->{'tags'}}), "\n" if exists $data->{'tags'}; + + # Priorities map to a 1-9 scale. + if (exists $data->{'priority'}) + { + print "PRIORITY:", ($data->{'priority'} eq 'H' ? '1' : + $data->{'priority'} eq 'M' ? '5' : + '9'), "\n"; + } + + # Status maps differently. + my $status = $data->{'status'}; + if ($status eq 'pending' || $status eq 'waiting') + { + print "STATUS:", (exists $data->{'start'} ? 'IN-PROCESS' : 'NEEDS-ACTION'), "\n"; + } + elsif ($status eq 'completed') + { + print "STATUS:COMPLETED\n"; + } + elsif ($status eq 'deleted') + { + print "STATUS:CANCELLED\n"; + } + + # Annotations become comments. + if (exists $data->{'annotations'}) + { + print "COMMENT:$_->{'description'}\n" for @{$data->{'annotations'}}; + } + + print "END:VTODO\n"; +} + +print "END:VCALENDAR\n"; +exit 0; + +################################################################################ + diff --git a/scripts/add-ons/export-xml.pl b/scripts/add-ons/export-xml.pl new file mode 100755 index 000000000..26c454580 --- /dev/null +++ b/scripts/add-ons/export-xml.pl @@ -0,0 +1,74 @@ +#! /usr/bin/perl +################################################################################ +## 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 +## +################################################################################ + +use strict; +use warnings; +use JSON; + +# Use the taskwarrior 1.9.4+ _query command to issue a query and return JSON +my $command = '/usr/local/bin/task _query ' . join (' ', @ARGV); + +# Generate output. +print "\n"; +for my $task (split /,$/ms, qx{$command}) +{ + my $data = from_json ($task); + + print " \n"; + for my $key (keys %$data) + { + if ($key eq 'annotations') + { + print " \n"; + for my $anno (@{$data->{$key}}) + { + print " \n"; + print " <$_>$anno->{$_}\n" for keys %$anno; + print " \n"; + } + print " \n"; + } + elsif ($key eq 'tags') + { + print " \n"; + print " $_\n" for @{$data->{'tags'}}; + print " \n"; + } + else + { + print " <$key>$data->{$key}\n"; + } + } + print " \n"; +} + +print "\n"; +exit 0; + +################################################################################ + diff --git a/scripts/add-ons/export-xml.py b/scripts/add-ons/export-xml.py new file mode 100755 index 000000000..848803f40 --- /dev/null +++ b/scripts/add-ons/export-xml.py @@ -0,0 +1,62 @@ +#! /usr/bin/python +################################################################################ +## 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 +## +################################################################################ + +import sys +import commands +import json + +# Use the taskwarrior 1.9.4+ _query command to issue a query and return JSON +command = "/usr/local/bin/task _query " + " ".join (sys.argv[1:]) + +# Generate output. +print "" +for task in commands.getoutput (command).split (",\n"): + data = json.loads (task) + print " " + for attribute in data.items (): + if attribute[0] == "annotations": + print " " + for anno in attribute[1]: + print " " + for item in anno.items (): + print " <{0}>{1}".format (item[0], item[1]) + print " " + print " " + elif attribute[0] == "tags": + print " " + for tag in attribute[1]: + print " {0}".format (tag) + print " " + else: + print " <{0}>{1}".format (attribute[0], attribute[1]) + print " " +print "" +sys.exit (0) + +################################################################################ + diff --git a/scripts/add-ons/export-xml.rb b/scripts/add-ons/export-xml.rb new file mode 100755 index 000000000..f3b3a2191 --- /dev/null +++ b/scripts/add-ons/export-xml.rb @@ -0,0 +1,67 @@ +#! /usr/bin/ruby +################################################################################ +## 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 +## +################################################################################ + +require 'rubygems' +require 'json' + +# Use the taskwarrior 1.9.4+ _query command to issue a query and return JSON +lines = IO.popen("/usr/local/bin/task _query " + ARGV.join(" ")).readlines + +# Generate output. +print "\n" +lines.each do |line| + data = JSON.parse(line) + print " \n" + data.each do |key,value| + if key == "annotations" + print " \n" + value.each do |anno| + print " \n" + anno.each do |key,value| + print " <#{key}>#{value}\n" + end + print " \n" + end + print " \n" + elsif key == "tags" + print " \n" + value.each do |tag| + print " #{tag}\n" + end + print " \n" + else + print " <#{key}>#{value}\n" + end + end + print " \n" +end +print "\n" +exit 0 + +################################################################################ + diff --git a/scripts/add-ons/export-yaml.pl b/scripts/add-ons/export-yaml.pl new file mode 100755 index 000000000..4d52725e1 --- /dev/null +++ b/scripts/add-ons/export-yaml.pl @@ -0,0 +1,72 @@ +#! /usr/bin/perl +################################################################################ +## 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 +## +################################################################################ + +use strict; +use warnings; +use JSON; + +# Use the taskwarrior 1.9.4+ _query command to issue a query and return JSON +my $command = '/usr/local/bin/task _query ' . join (' ', @ARGV); + +# Generate output. +print "%YAML 1.1\n", + "---\n"; + +for my $task (split /,$/ms, qx{$command}) +{ + my $data = from_json ($task); + + print " task:\n"; + for my $key (keys %$data) + { + if ($key eq 'annotations') + { + print " annotations:\n"; + for my $anno (@{$data->{$key}}) + { + print " annotation:\n"; + print " $_:$anno->{$_}\n" for keys %$anno; + } + } + elsif ($key eq 'tags') + { + print " tags:\n"; + print " tag:$_\n" for @{$data->{'tags'}}; + } + else + { + print " $key:$data->{$key}\n"; + } + } +} + +print "...\n"; +exit 0; + +################################################################################ +