diff --git a/scripts/add-ons/README b/scripts/add-ons/README new file mode 100644 index 000000000..0a9799cde --- /dev/null +++ b/scripts/add-ons/README @@ -0,0 +1,3 @@ +The import/export add-on scripts have been relocated online. Please see: + +https://taskwarrior.org/tools/#exts diff --git a/scripts/add-ons/export-csv.pl b/scripts/add-ons/export-csv.pl deleted file mode 100755 index eebd631bf..000000000 --- a/scripts/add-ons/export-csv.pl +++ /dev/null @@ -1,85 +0,0 @@ -#! /usr/bin/perl -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -use strict; -use warnings; - -# Give a nice error if the (non-standard) JSON module is not installed. -eval "use JSON"; -if ($@) -{ - print "Error: You need to install the JSON Perl module.\n"; - exit 1; -} - -# Use the taskwarrior 2.0+ export command to filter and return JSON -my $command = join (' ', ("env PATH=$ENV{PATH} task rc.verbose=nothing rc.json.array=no export", @ARGV)); -if ($command =~ /No matches/) -{ - printf STDERR $command; - exit 1; -} - -# Generate output. -print "'uuid','status','tags','entry','start','due','recur','end','project',", - "'priority','fg','bg','description'\n"; - -for my $task (split "\n", qx{$command}) -{ - my $data = from_json ($task); - - my $desc = $data->{'description'}; - $desc =~ s/'/\\'/g; - - 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'} || ''), "',", - "'$desc'", - "\n"; - - # Note that this format ignores: - # wait - # until - # annotations - # mask - # imask - # UDAs -} - -exit 0; - -################################################################################ - diff --git a/scripts/add-ons/export-html.pl b/scripts/add-ons/export-html.pl deleted file mode 100755 index 27832875e..000000000 --- a/scripts/add-ons/export-html.pl +++ /dev/null @@ -1,90 +0,0 @@ -#! /usr/bin/perl -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -use strict; -use warnings; - -# Give a nice error if the (non-standard) JSON module is not installed. -eval "use JSON"; -if ($@) -{ - print "Error: You need to install the JSON Perl module.\n"; - exit 1; -} - -# Use the taskwarrior 2.0+ export command to filter and return JSON -my $command = join (' ', ("env PATH='$ENV{PATH}' task rc.verbose=nothing rc.json.array=no export", @ARGV)); -if ($command =~ /No matches/) -{ - printf STDERR $command; - exit 1; -} - -# Generate output. -print "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n"; - -my $count = 0; -for my $task (split "\n", qx{$command}) -{ - ++$count; - my $data = from_json ($task); - - print " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n"; -} - -print " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
IDPriDescriptionProjectDue
", ($data->{'id'} || ''), "", ($data->{'priority'} || ''), "", ($data->{'description'} || ''), "", ($data->{'project'} || ''), "", ($data->{'due'} || ''), "
", $count, " matching tasks
\n", - " \n", - "\n"; - -exit 0; - -################################################################################ - diff --git a/scripts/add-ons/export-ical.pl b/scripts/add-ons/export-ical.pl deleted file mode 100755 index 75ce8f803..000000000 --- a/scripts/add-ons/export-ical.pl +++ /dev/null @@ -1,102 +0,0 @@ -#! /usr/bin/perl -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -use strict; -use warnings; - -# Give a nice error if the (non-standard) JSON module is not installed. -eval "use JSON"; -if ($@) -{ - print "Error: You need to install the JSON Perl module.\n"; - exit 1; -} - -# Use the taskwarrior 2.0+ export command to filter and return JSON -my $command = join (' ', ("env PATH=$ENV{PATH} task rc.verbose=nothing rc.json.array=no export", @ARGV)); -if ($command =~ /No matches/) -{ - printf STDERR $command; - exit 1; -} - -# Generate output. -print "BEGIN:VCALENDAR\n", - "VERSION:2.0\n", - "PRODID:=//GBF/taskwarrior 1.9.4//EN\n"; - -for my $task (split "\n", 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-sql.py b/scripts/add-ons/export-sql.py deleted file mode 100755 index 02c0d354b..000000000 --- a/scripts/add-ons/export-sql.py +++ /dev/null @@ -1,170 +0,0 @@ -#! /usr/bin/python -############################################################################### -# -# Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# -# http://www.opensource.org/licenses/mit-license.php -# -############################################################################### -""" -export-sql.py -- Export the taskwarrior database as a series of SQL commands. - -Example usage:: - - $ PYTHONIOENCODING=UTF-8 ./export-sql.py | sqlite3 mytasks.db - $ /usr/bin/sqlite3 mytasks.db "select * from annotations;" - -This script has only been tested with sqlite3, but in theory, it could be -easily modified to supported mysql, postgres or whatever you choose. - -Author: Ralph Bean -""" - -import sys -import commands -import json - -from datetime import datetime - -# Note that you may want to modify the field sizes to suit your usage. -table_definitions = """ -CREATE TABLE tasks ( - uuid VARCHAR(255) NOT NULL, - description VARCHAR(255) NOT NULL, - entry DATETIME NOT NULL, - end DATETIME, - priority VARCHAR(32), - project VARCHAR(32), - status VARCHAR(32), - PRIMARY KEY (uuid) -); - -CREATE TABLE annotations ( - uuid VARCHAR(255) NOT NULL, - description VARCHAR(255) NOT NULL, - entry DATETIME NOT NULL, - FOREIGN KEY(uuid) REFERENCES tasks(uuid) -); -""" - - -replacements = { - '"': '&dquot;', - "'": '"', - '[': '&open;', - ']': '&close;', - '/': '\\/', -} - - -def escape(s): - """ Escape a string in the taskwarrior style """ - - for unsafe, safe in replacements.iteritems(): - s = s.replace(unsafe, safe) - return s - - -# A lookup table for how to convert various values by type to SQL -conversion_lookup = { - # Tack on an extra set of quotes - unicode: lambda v: "'%s'" % escape(v), - # Do the same as for unicode - str: lambda v: convert(unicode(v)), - # Convert to ISO format and do the same as for unicode - datetime: lambda v: convert(v.isoformat(' ')), - # Replace python None with SQL NULL - type(None): lambda v: 'NULL', -} - -# Compose a value with its corresponding function in conversion_lookup -convert = lambda v: conversion_lookup.get(type(v), lambda v: v)(v) - - -def parse_datetime(task): - """ Parse the datetime strings given to us by `task export` """ - - for key in ['entry', 'end']: - if key in task: - task[key] = datetime.strptime(task[key], "%Y%m%dT%H%M%SZ") - return task - - -def to_sql(task): - """ Create a list of SQL INSERT statements out of a task python dict """ - - def make_annotation(annot): - """ Create a list of SQL INSERT statements for an annotation """ - - annot['uuid'] = task['uuid'] - template = "{uuid}, {description}, {entry}" - annot = dict(zip(annot.keys(), map(convert, annot.values()))) - values = template.format(**annot) - return "INSERT INTO \"annotations\" VALUES(%s)" % values - - template = u"{uuid}, {description}, {entry}, {end}, " + \ - u"{priority}, {project}, {status}" - - nullables = ['end', 'priority', 'project', 'status'] - defaults = dict([(key, None) for key in nullables]) - defaults['annotations'] = [] - defaults.update(task) - - defaults = dict(zip(defaults.keys(), map(convert, defaults.values()))) - - values = template.format(**defaults) - annotations = map(make_annotation, defaults['annotations']) - - return ["INSERT INTO \"tasks\" VALUES(%s)" % values] + annotations - - -def main(): - """ Return a list of SQL statements. """ - - # Use the taskwarrior 2.0+ export command to filter and return JSON - command = "task rc.verbose=nothing rc.json.array=yes " + " ".join(sys.argv[1:]) + " export" - - # Load each task from json to a python dict - tasks = json.loads(commands.getoutput(command)) - - # Mangle datetime strings into python datetime objects - tasks = map(parse_datetime, tasks) - - # Produce formatted SQL statements for each task - inserts = sum(map(to_sql, tasks), []) - - return inserts - - -if __name__ == '__main__': - # Get the INSERT statements - lines = main() - - # Combine them with semicolons - sql = table_definitions + ";\n".join(lines) + ';' - - # Print them out, decorated with sqlite3 trappings - print u""" -BEGIN TRANSACTION; -{sql} -COMMIT;""".format(sql=sql) - -############################################################################### diff --git a/scripts/add-ons/export-tsv.pl b/scripts/add-ons/export-tsv.pl deleted file mode 100755 index a51e3994c..000000000 --- a/scripts/add-ons/export-tsv.pl +++ /dev/null @@ -1,82 +0,0 @@ -#! /usr/bin/perl -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -use strict; -use warnings; - -# Give a nice error if the (non-standard) JSON module is not installed. -eval "use JSON"; -if ($@) -{ - print "Error: You need to install the JSON Perl module.\n"; - exit 1; -} - -# Use the taskwarrior 2.0+ export command to filter and return JSON -my $command = join (' ', ("env PATH=$ENV{PATH} task rc.verbose=nothing rc.json.array=no export", @ARGV)); -if ($command =~ /No matches/) -{ - printf STDERR $command; - exit 1; -} - -# Generate output. -print "uuid\tstatus\ttags\tentry\tstart\tdue\trecur\tend\tproject\t", - "priority\tfg\tbg\tdescription\n"; - -for my $task (split "\n", qx{$command}) -{ - my $data = from_json ($task); - - print "$data->{'uuid'}\t", - "$data->{'status'}\t", - (exists $data->{'tags'} ? join (' ', @{$data->{'tags'}}) : ''), "\t", - "$data->{'entry'}\t", - ($data->{'start'} || ''), "\t", - ($data->{'due'} || ''), "\t", - ($data->{'recur'} || ''), "\t", - ($data->{'end'} || ''), "\t", - ($data->{'project'} || ''), "\t", - ($data->{'priority'} || ''), "\t", - ($data->{'fg'} || ''), "\t", - ($data->{'bg'} || ''), "\t", - "$data->{'description'}", - "\n"; - - # Note that this format ignores: - # wait - # until - # annotations - # mask - # imask - # UDAs -} - -exit 0; - -################################################################################ - diff --git a/scripts/add-ons/export-xml.pl b/scripts/add-ons/export-xml.pl deleted file mode 100755 index c0763ac1d..000000000 --- a/scripts/add-ons/export-xml.pl +++ /dev/null @@ -1,85 +0,0 @@ -#! /usr/bin/perl -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -use strict; -use warnings; - -# Give a nice error if the (non-standard) JSON module is not installed. -eval "use JSON"; -if ($@) -{ - print "Error: You need to install the JSON Perl module.\n"; - exit 1; -} - -# Use the taskwarrior 2.0+ export command to filter and return JSON -my $command = join (' ', ("env PATH=$ENV{PATH} task rc.verbose=nothing rc.json.array=no export", @ARGV)); -if ($command =~ /No matches/) -{ - printf STDERR $command; - exit 1; -} - -# Generate output. -print "\n"; -for my $task (split "\n", 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 deleted file mode 100755 index 87898aac7..000000000 --- a/scripts/add-ons/export-xml.py +++ /dev/null @@ -1,61 +0,0 @@ -#! /usr/bin/python -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -import sys -import commands -import json - -# Use the taskwarrior 2.0+ export command to filter and return JSON -command = "/usr/local/bin/task rc.verbose=nothing rc.json.array=no export " + " ".join (sys.argv[1:]) - -# Generate output. -print "" -for task in commands.getoutput (command).split (",\n"): - data = json.loads (task) - print " " - for name,value in data.items (): - if name == "annotations": - print " " - for anno in value: - print " " - for name,value in anno.items (): - print " <{0}>{1}".format (name, value) - print " " - print " " - elif name == "tags": - print " " - for tag in value: - print " {0}".format (tag) - print " " - else: - print " <{0}>{1}".format (name, value) - print " " -print "" -sys.exit (0) - -################################################################################ - diff --git a/scripts/add-ons/export-xml.rb b/scripts/add-ons/export-xml.rb deleted file mode 100755 index c6ab17e7f..000000000 --- a/scripts/add-ons/export-xml.rb +++ /dev/null @@ -1,66 +0,0 @@ -#! /usr/bin/ruby -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -require 'rubygems' -require 'json' - -# Use the taskwarrior 2.0+ export command to filter and return JSON -lines = IO.popen("/usr/local/bin/task rc.verbose=nothing rc.json.array=no export " + 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-yad.pl b/scripts/add-ons/export-yad.pl deleted file mode 100755 index e20589059..000000000 --- a/scripts/add-ons/export-yad.pl +++ /dev/null @@ -1,81 +0,0 @@ -#! /usr/bin/perl -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -use strict; -use warnings; - -# Give a nice error if the (non-standard) JSON module is not installed. -eval "use JSON"; -if ($@) -{ - print "Error: You need to install the JSON Perl module.\n"; - exit 1; -} - -# Use the taskwarrior 2.0+ export command to filter and return JSON -my $command = join (' ', ("env PATH=$ENV{PATH} task rc.verbose=nothing rc.json.array=no export", @ARGV)); -if ($command =~ /No matches/) -{ - printf STDERR $command; - exit 1; -} - -# Generate output. -print "'uuid','status','tags','entry','start','due','recur','end','project',", - "'priority','fg','bg','description'\n"; - -for my $task (split "\n", 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-yaml.pl b/scripts/add-ons/export-yaml.pl deleted file mode 100755 index a37b62638..000000000 --- a/scripts/add-ons/export-yaml.pl +++ /dev/null @@ -1,79 +0,0 @@ -#! /usr/bin/perl -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -use strict; -use warnings; - -# Give a nice error if the (non-standard) JSON module is not installed. -eval "use JSON"; -if ($@) -{ - print "Error: You need to install the JSON Perl module.\n"; - exit 1; -} - -# Generate output. -print "%YAML 1.1\n", - "---\n"; - -while (my $json = <>) -{ - $json =~ s/^\[//; - $json =~ s/\]$//; - $json =~ s/,$//; - next if $json eq ''; - - my $data = from_json ($json); - - print " task:\n"; - for my $key (sort 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: ", join (',', @{$data->{'tags'}}), "\n"; - } - else - { - print " $key: $data->{$key}\n"; - } - } -} - -print "...\n"; -exit 0; - -################################################################################ - diff --git a/scripts/add-ons/import-todo.sh.pl b/scripts/add-ons/import-todo.sh.pl deleted file mode 100755 index 37be9ae02..000000000 --- a/scripts/add-ons/import-todo.sh.pl +++ /dev/null @@ -1,162 +0,0 @@ -#! /usr/bin/perl -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -use strict; -use warnings; -use Time::Local; - -# Priority mappings. -my %priority_map = ( - 'a' => 'H', 'b' => 'M', 'c' => 'L', 'd' => 'L', 'e' => 'L', 'f' => 'L', - 'g' => 'L', 'h' => 'L', 'i' => 'L', 'j' => 'L', 'k' => 'L', 'l' => 'L', - 'm' => 'L', 'n' => 'L', 'o' => 'L', 'p' => 'L', 'q' => 'L', 'r' => 'L', - 's' => 'L', 't' => 'L', 'u' => 'L', 'v' => 'L', 'w' => 'L', 'x' => 'L', - 'y' => 'L', 'z' => 'L'); - -my @tasks; -while (my $todo = <>) -{ - my $status = 'pending'; - my $priority = ''; - my $entry = ''; - my $end = ''; - my @projects; - my @contexts; - my $description = ''; - my $due = ''; - - # pending + pri + entry - if ($todo =~ /^\(([A-Z])\)\s(\d{4}-\d{2}-\d{2})\s(.+)$/i) - { - ($status, $priority, $entry, $description) = ('pending', $1, epoch ($2), $3); - } - - # pending + pri - elsif ($todo =~ /^\(([A-Z])\)\s(.+)$/i) - { - ($status, $priority, $description) = ('pending', $1, $2); - } - - # pending + entry - elsif ($todo =~ /^(\d{4}-\d{2}-\d{2})\s(.+)$/i) - { - ($status, $entry, $description) = ('pending', epoch ($1), $2); - } - - # done + end + entry - elsif ($todo =~ /^x\s(\d{4}-\d{2}-\d{2})\s(\d{4}-\d{2}-\d{2})\s(.+)$/i) - { - ($status, $end, $entry, $description) = ('completed', epoch ($1), epoch ($2), $3); - } - - # done + end - elsif ($todo =~ /^x\s(\d{4}-\d{2}-\d{2})\s(.+)$/i) - { - ($status, $end, $description) = ('completed', epoch ($1), $2); - } - - # done - elsif ($todo =~ /^x\s(.+)$/i) - { - ($status, $description) = ('completed', $1); - } - - # pending - elsif ($todo =~ /^(.+)$/i) - { - ($status, $description) = ('pending', $1); - } - - # Project - @projects = $description =~ /\+(\S+)/ig; - - # Contexts - @contexts = $description =~ /\@(\S+)/ig; - - # Due - $due = epoch ($1) if $todo =~ /\sdue:(\d{4}-\d{2}-\d{2})/i; - - # Map priorities - $priority = $priority_map{lc $priority} if $priority ne ''; - - # Pick first project - my $first_project = shift @projects; - - # Compose the JSON - my $json = ''; - $json .= "{\"status\":\"${status}\""; - $json .= ",\"priority\":\"${priority}\"" if defined $priority && $priority ne ''; - $json .= ",\"project\":\"${first_project}\"" if defined $first_project && $first_project ne ''; - $json .= ",\"entry\":\"${entry}\"" if $entry ne ''; - $json .= ",\"end\":\"${end}\"" if $end ne ''; - $json .= ",\"due\":\"${due}\"" if $due ne ''; - - if (@contexts) - { - $json .= ",\"tags\":[" . join (',', map {"\"$_\""} @contexts) . "]"; - } - - $json .= ",\"description\":\"${description}\"}"; - - push @tasks, $json; -} - -print "[\n", join ("\n", @tasks), "\n]\n"; -exit 0; - -################################################################################ -sub epoch -{ - my ($input) = @_; - - my ($y, $m, $d) = $input =~ /(\d{4})-(\d{2})-(\d{2})/; - return timelocal (0, 0, 0, $d, $m-1, $y-1900); -} - -################################################################################ - -__DATA__ -(A) Thank Mom for the meatballs @phone -(B) Schedule Goodwill pickup +GarageSale @phone -Post signs around the neighborhood +GarageSale -@GroceryStore Eskimo pies -(A) Thank Mom for the meatballs @phone -(B) Schedule Goodwill pickup +GarageSale @phone -(B) Schedule Goodwill pickup +GarageSale @phone -Post signs around the neighborhood +GarageSale -Really gotta call Mom (A) @phone @someday -(b) Get back to the boss -(B)->Submit TPS report -2011-03-02 Document +TodoTxt task format -(A) 2011-03-02 Call Mom -(A) Call Mom 2011-03-02 -(A) Call Mom +Family +PeaceLoveAndHappiness @iphone @phone -x 2011-03-03 Call Mom -xylophone lesson -X 2012-01-01 Make resolutions -(A) x Find ticket prices -x 2011-03-02 2011-03-01 Review Tim's pull request +TodoTxtTouch @github diff --git a/scripts/add-ons/import-yaml.pl b/scripts/add-ons/import-yaml.pl deleted file mode 100755 index 9ec6c50f1..000000000 --- a/scripts/add-ons/import-yaml.pl +++ /dev/null @@ -1,141 +0,0 @@ -#! /usr/bin/perl -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -use strict; -use warnings; -use Time::Local; - -my @tasks; - -my $status = ''; -my $uuid = ''; -my $priority = ''; -my $entry = ''; -my $end = ''; -my $project = ''; -my $tags = ''; -my $description = ''; -my $due = ''; - -my %annotations; -my $mid_anno = 0; -my $anno_entry = ''; -my $anno_desc = ''; - -while (my $yaml = <>) -{ - chomp $yaml; - next if $yaml =~ /\sid:/; - next if $yaml =~ /\sannotations:/; - - if ($yaml =~ /task:|\.\.\./ && $description ne '') - { - # Compose the JSON - my $json = "{\"status\":\"${status}\""; - $json .= ",\"uuid\":\"${uuid}\"" if $uuid ne ''; - $json .= ",\"priority\":\"${priority}\"" if $priority ne ''; - $json .= ",\"project\":\"${project}\"" if $project ne ''; - $json .= ",\"entry\":\"${entry}\"" if $entry ne ''; - $json .= ",\"end\":\"${end}\"" if $end ne ''; - $json .= ",\"due\":\"${due}\"" if $due ne ''; - if ($tags ne '') - { - $tags =~ s/,/","/g; - $json .= ",\"tags\":[\"${tags}\"]"; - } - if (%annotations) - { - $json .= ",\"annotations\":["; - my $pre = ""; - for my $key (sort keys %annotations) { - $json .= "${pre}{\"entry\":\"${key}\",\"description\":\"${annotations{$key}}\"}"; - $pre = ","; - } - $json .= "]"; - } - $json .= ",\"description\":\"${description}\"}"; - - push @tasks, $json; - - $status = $uuid = $priority = $entry = $end = $project = $tags = - $description = $due = $anno_entry = $anno_desc = ''; - $mid_anno = 0; - %annotations = (); - $yaml = ''; - } - else - { - $mid_anno = 1 if $yaml =~ /annotation:/; - $anno_entry = $1 if $mid_anno && $yaml =~ /entry:\s*(\S+)/; - if ($mid_anno) - { - if ($yaml =~ /description:\s*(.+)/) - { - $anno_desc = $1; - $mid_anno = 0; - - $annotations{$anno_entry} = $anno_desc; - } - } - else - { - $entry = $1 if $yaml =~ /entry:\s*(\S+)/; - $description = $1 if $yaml =~ /description:\s*(.+)/; - } - - $status = $1 if $yaml =~ /status:\s*(\S+)/; - $uuid = $1 if $yaml =~ /uuid:\s*(\S+)/; - $priority = $1 if $yaml =~ /priority:\s*(\S+)/; - $project = $1 if $yaml =~ /project:\s*(\S+)/; - $end = $1 if $yaml =~ /end:\s*(\S+)/; - $due = $1 if $yaml =~ /due:\s*(\S+)/; - $tags = $1 if $yaml =~ /tags:\s*(\S+)/; - } -} - -print "[\n", join ("\n", @tasks), "\n]\n"; -exit 0; - -################################################################################ - -__DATA__ -%YAML 1.1 ---- - task: - annotations: - annotation: - entry: 20100706T025311Z - description: Also needs to ignore control codes - description: text.cpp/extractLines needs to calculate string length in a way that supports UTF8 - entry: 20090319T151633Z - id: 9 - project: task-2.0 - status: pending - tags: bug,utf8,next - uuid: 0c4cf066-9413-4862-9dc8-0793f158a649 -... - diff --git a/test/README b/test/README index 79447b5b9..6a62a6d93 100644 --- a/test/README +++ b/test/README @@ -33,9 +33,9 @@ Architecture There are three varieties of tests: - * Perl unit tests that use Test::More and the JSON module. We are phasing - these out, and will accept no new Perl tests. These tests are high level - and exercise Taskwarrior at the command line level. + * Perl unit tests that use Test::More module. We are phasing these out, and + will accept no new Perl tests. These tests are high level and exercise + Taskwarrior at the command line level. * C++ unit tests that test low-level object interfaces. These are typically very fast tests, and are exhaustive in nature. diff --git a/test/export.yaml.t b/test/export.yaml.t deleted file mode 100755 index 5108e2ddd..000000000 --- a/test/export.yaml.t +++ /dev/null @@ -1,91 +0,0 @@ -#! /usr/bin/env perl -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -use strict; -use warnings; -use Test::More tests => 22; - -# Ensure environment has no influence. -delete $ENV{'TASKDATA'}; -delete $ENV{'TASKRC'}; - -use File::Basename; -my $ut = basename ($0); -my $rc = $ut . '.rc'; - -my $source_dir = $0; -$source_dir =~ s{[^/]+$}{..}; - -# Create the rc file. -if (open my $fh, '>', $rc) -{ - print $fh "data.location=.\n", - "verbose=no\n", - "json.array=off"; - close $fh; -} - -# Add two tasks, export, examine result. -# TODO Add annotations. -qx{../src/task rc:$rc add priority:H project:A one 2>&1}; -qx{../src/task rc:$rc add +tag1 +tag2 two 2>&1}; - -my $output = qx{../src/task rc:$rc export | $source_dir/scripts/add-ons/export-yaml.pl > ./export.txt 2>&1}; -my @lines; -if (open my $fh, '<', './export.txt') -{ - @lines = <$fh>; - close $fh; -} - -like ($lines[0], qr/^\%YAML 1\.1$/, "$ut: export YAML line 1"); -like ($lines[1], qr/^---$/, "$ut: export YAML line 2"); -like ($lines[2], qr/^ task:$/, "$ut: export YAML line 3"); -like ($lines[3], qr/^ description: one$/, "$ut: export YAML line 4"); -like ($lines[4], qr/^ entry: \d{8}T\d{6}Z$/, "$ut: export YAML line 5"); -like ($lines[5], qr/^ id: \d+$/, "$ut: export YAML line 6"); -like ($lines[6], qr/^ modified: \d{8}T\d{6}Z$/, "$ut: export YAML line 7"); -like ($lines[7], qr/^ priority: H$/, "$ut: export YAML line 8"); -like ($lines[8], qr/^ project: A$/, "$ut: export YAML line 9"); -like ($lines[9], qr/^ status: pending$/, "$ut: export YAML line 10"); -like ($lines[10], qr/^ urgency: .+$/, "$ut: export YAML line 11"); -like ($lines[11], qr/^ uuid: .+$/, "$ut: export YAML line 12"); -like ($lines[12], qr/^ task:$/, "$ut: export YAML line 13"); -like ($lines[13], qr/^ description: two$/, "$ut: export YAML line 14"); -like ($lines[14], qr/^ entry: \d{8}T\d{6}Z$/, "$ut: export YAML line 15"); -like ($lines[15], qr/^ id: \d+$/, "$ut: export YAML line 16"); -like ($lines[16], qr/^ modified: \d{8}T\d{6}Z$/, "$ut: export YAML line 17"); -like ($lines[17], qr/^ status: pending$/, "$ut: export YAML line 18"); -like ($lines[18], qr/^ tags: tag1,tag2$/, "$ut: export YAML line 19"); -like ($lines[19], qr/^ urgency: .+$/, "$ut: export YAML line 20"); -like ($lines[20], qr/^ uuid: .+$/, "$ut: export YAML line 21"); -like ($lines[21], qr/^\.\.\.$/, "$ut: export YAML line 22"); - -# Cleanup. -unlink qw(pending.data completed.data undo.data backlog.data export.txt), $rc; -exit 0; - diff --git a/test/import.todo.sh.t b/test/import.todo.sh.t deleted file mode 100755 index 8754e822b..000000000 --- a/test/import.todo.sh.t +++ /dev/null @@ -1,129 +0,0 @@ -#! /usr/bin/env perl -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -use strict; -use warnings; -use Test::More tests => 23; - -# Ensure environment has no influence. -delete $ENV{'TASKDATA'}; -delete $ENV{'TASKRC'}; - -my $source_dir = $0; -$source_dir =~ s{[^/]+$}{..}; - -# Create the rc file. -if (open my $fh, '>', 'import.rc') -{ - print $fh "data.location=.\n", - "json.array=on\n", - "dateformat=YYYY-M-D\n", - "verbose=off\n"; - close $fh; -} - -# Create import file. -if (open my $fh, '>', 'import.txt') -{ - print $fh "(A) \@phone thank Mom for the meatballs\n", # 1 - "(B) +GarageSale \@phone schedule Goodwill pickup\n", # 2 - "+GarageSale \@home post signs around the neighborhood\n", # 3 - "\@shopping Eskimo pies\n", # 4 - "(A) Call Mom\n", # 5 - "Really gotta call Mom (A) \@phone \@someday\n", # 6 - "(b)->get back to the boss\n", # 7 - "2011-03-02 Document +TodoTxt task format\n", # 8 - "(A) 2011-03-02 Call Mom\n", # 9 - "(A) Call Mom 2011-03-02\n", # 10 - "(A) Call Mom +Family +PeaceLoveAndHappiness \@iphone \@phone\n", # 11 - "xylophone lesson\n", # 12 - "X 2011-03-03 Call Mom\n", # - - "x 2011-03-02 2011-03-01 Review Tim's pull request +TodoTxtTouch \@github\n"; # - - - close $fh; -} - -# Convert todo.sh --> task JSON. -qx{$source_dir/scripts/add-ons/import-todo.sh.pl import.json 2>&1}; - -# Import the JSON. -my $output = qx{../src/task rc:import.rc import import.json 2>&1}; -diag ($output); - -$output = qx{../src/task rc:import.rc info 1 2>&1}; -like ($output, qr/^Priority.+H/ms, '1 pri:H'); -like ($output, qr/^Tags.+phone/ms, '1 +phone'); -like ($output, qr/^Description.+\@phone thank Mom for the meatballs/ms, '1 '); - -$output = qx{../src/task rc:import.rc info 2 2>&1}; -like ($output, qr/^Priority.+M/ms, '2 pri:M'); -like ($output, qr/^Project.+GarageSale/ms, '2 '); -like ($output, qr/^Description.+/ms, '2 '); - -$output = qx{../src/task rc:import.rc info 3 2>&1}; -like ($output, qr/^Project.+GarageSale/ms, '3 '); -like ($output, qr/^Description.+\+GarageSale \@home post signs around the neighborhood/ms, '3 '); - -$output = qx{../src/task rc:import.rc info 4 2>&1}; -like ($output, qr/^Description.+\@shopping Eskimo pies/ms, '4 '); - -$output = qx{../src/task rc:import.rc info 5 2>&1}; -like ($output, qr/^Priority.+H/ms, '5 pri:H'); -like ($output, qr/^Description.+Call Mom/ms, '5 '); - -$output = qx{../src/task rc:import.rc info 6 2>&1}; -like ($output, qr/^Description.+Really gotta call Mom \(A\) \@phone \@someday/ms, '6 '); - -$output = qx{../src/task rc:import.rc info 7 2>&1}; -like ($output, qr/^Description.+\(b\)->get back to the boss/ms, '7 '); - -$output = qx{../src/task rc:import.rc info 8 2>&1}; -like ($output, qr/^Project.+TodoTxt/ms, '8 '); -like ($output, qr/^Description.+Document \+TodoTxt task format/ms, '8 '); - -$output = qx{../src/task rc:import.rc info 9 2>&1}; -like ($output, qr/^Priority.+H/ms, '9 pri:H'); -like ($output, qr/^Description.+Call Mom/ms, '9 '); - -$output = qx{../src/task rc:import.rc info 10 2>&1}; -like ($output, qr/^Priority.+H/ms, '10 pri:H'); -like ($output, qr/^Description.+Call Mom 2011-03-02/ms, '10 '); - -$output = qx{../src/task rc:import.rc info 11 2>&1}; -like ($output, qr/^Priority.+H/ms, '11 pri:H'); -like ($output, qr/^Project.+Family/ms, '8 '); -like ($output, qr/^Description.+Call Mom \+Family \+PeaceLoveAndHappiness \@iphone \@phone/ms, '11 '); - -$output = qx{../src/task rc:import.rc info 12 2>&1}; -like ($output, qr/^Description.+xylophone lesson/ms, '12 '); - -# TODO and now the completed ones. - -# Cleanup. -unlink qw(pending.data completed.data undo.data backlog.data import.rc import.txt import.json); -exit 0; - diff --git a/test/import.yaml.t b/test/import.yaml.t deleted file mode 100755 index d835061e1..000000000 --- a/test/import.yaml.t +++ /dev/null @@ -1,178 +0,0 @@ -#! /usr/bin/env perl -################################################################################ -## -## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. -## -## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to deal -## in the Software without restriction, including without limitation the rights -## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -## copies of the Software, and to permit persons to whom the Software is -## furnished to do so, subject to the following conditions: -## -## The above copyright notice and this permission notice shall be included -## in all copies or substantial portions of the Software. -## -## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -## SOFTWARE. -## -## http://www.opensource.org/licenses/mit-license.php -## -################################################################################ - -use strict; -use warnings; -use Test::More tests => 15; - -# Ensure environment has no influence. -delete $ENV{'TASKDATA'}; -delete $ENV{'TASKRC'}; - -use File::Basename; -my $ut = basename ($0); -my $rc = $ut . '.rc'; - -my $source_dir = $0; -$source_dir =~ s{[^/]+$}{..}; - -# Create the rc file. -if (open my $fh, '>', $rc) -{ - print $fh "data.location=.\n", - "dateformat=m/d/Y\n"; - close $fh; -} - -# Create import file. -if (open my $fh, '>', 'import.txt') -{ - print $fh < task JSON. -qx{$source_dir/scripts/add-ons/import-yaml.pl import.json 2>&1}; - -# Import the JSON. -my $output = qx{../src/task rc:$rc import import.json 2>&1 >/dev/null}; -like ($output, qr/Imported 3 tasks\./, "$ut: 3 tasks imported"); - -$output = qx{../src/task rc:$rc list 2>&1}; -# ID Project Age Description -# -- ------- ------- ----------- -# 1 A 1.5 yrs zero -# 2 B 1.5 yrs one -# -# 2 tasks - -like ($output, qr/1.+A.+zero/, "$ut: t1 present"); -like ($output, qr/2.+B.+one/, "$ut: t2 present"); -unlike ($output, qr/3.+two/, "$ut: t3 missing"); - -$output = qx{../src/task rc:$rc completed 2>&1}; -# Complete Age Description UUID -# ---------- ---- ----------- ------------------------------------ -# 9/4/2011 2.9y two 22222222-2222-2222-2222-222222222222 -# -# 1 task - -unlike ($output, qr/A.+zero/, "$ut: t1 missing"); -unlike ($output, qr/B.+one/, "$ut: t2 missing"); -like ($output, qr/9\/4\/2011.+two/, "$ut: t3 present"); - -# check tags and annotations -$output = qx{../src/task rc:$rc +y 2>&1}; -# ID Proj Age Urg Description -# -- ---- ---- ---- ----------------------- -# 2 B 2.9y 4.9 one -# 7/6/2011 anno TWO -# 7/6/2012 anno THREE -# 1 A 2.9y 4.8 zero -# 7/6/2010 anno ONE -# -# 2 tasks -like ($output, qr/1.+A.+zero.*\n.+ONE/, "$ut: t1 selected by tag, has annotation"); -like ($output, qr/2.+B.+one.*\n.+TWO.*\n.+THREE/, "$ut: t2 selected by tag, has two annotations"); -like ($output, qr/\n2 tasks\n/, "$ut: tag selected two tasks"); - -# Create import file. -if (open my $fh, '>', 'import.txt') -{ - print $fh < task JSON. -qx{$source_dir/scripts/add-ons/import-yaml.pl import.json 2>&1}; - -# Import the JSON. -$output = qx{../src/task rc:$rc import import.json 2>&1 >/dev/null}; -like ($output, qr/Imported 1 tasks\./, "$ut: 1 task imported"); - -# Verify. -$output = qx{../src/task rc:$rc list 2>&1}; -# ID Project Pri Due Active Age Description -# -- ------- --- --- ------ ---- ----------- -# 3 2.6y three -# 1 A 3d zero -# 2 B 2d one -like ($output, qr/1.+A.+zero/, "$ut: t1 present"); -like ($output, qr/2.+B.+one/, "$ut: t2 present"); -like ($output, qr/3.+three/, "$ut: t3 present"); - -# Cleanup. -unlink qw(pending.data completed.data undo.data backlog.data import.txt import.json), $rc; -exit 0; -