diff --git a/ChangeLog b/ChangeLog index 73ef4c4ff..eb6cafe04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -50,6 +50,9 @@ + Added feature #523 & #659, adding 'status' as a reportable field (thanks to Peter De Poorter and Bryce Harrington). + Added feature #545, #610, #611, #646, which support complex aliases. + + Added feature #559, that causes Taskwarrior to exit if the ~/.task (or + rc.data.location override) does not exist, controlled by the + rc.exit.on.missing.db configuration variable (thanks to Sander Marechal). + Added feature #657 & #658, using the 'ids' command, tasks matching a filter can now be modified as a group (thanks to Bryce Harrington, Eric Fluger). + Added feature #679, which makes color rules match project names in a left- diff --git a/NEWS b/NEWS index 99cb34678..dbb9eb480 100644 --- a/NEWS +++ b/NEWS @@ -50,6 +50,8 @@ New configuration options in taskwarrior 2.0.0 '[...]'. - New 'regex' control determines whether substitutions use Regular Expressions or simple text patterns. + - New 'exit.on.missing.db' control causes an exit if the ~/.task directory + (or override) is missing. Newly deprecated features in taskwarrior 2.0.0 diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index 95215559c..430b7df7c 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -153,6 +153,11 @@ don't change. Note that this should be used in the form of a command line override (task rc.gc=off ...), and not permanently used in the .taskrc file, as this significantly affects performance. +.TP +.B exit.on.missing.db=no +When set to 'yes' causes the program to exit if the database (~/.task or +rc.data.location override) is missing. Default value is 'no'. + .SS TERMINAL .TP .B detection=on diff --git a/src/Config.cpp b/src/Config.cpp index fede784fe..50438e5ce 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -66,6 +66,7 @@ std::string Config::defaults = "data.location=~/.task\n" "locking=on # Use file-level locking\n" "gc=on # Garbage-collect data files - DO NOT CHANGE unless you are sure\n" + "exit.on.missing.db=no # Whether to exit if ~/.task is not found\n" "\n" "# Terminal\n" "detection=on # Detects terminal width\n" @@ -596,7 +597,12 @@ void Config::createDefaultData (const std::string& data) { Directory d (data); if (! d.exists ()) + { + if (getBoolean ("exit.on.missing.db")) + throw std::string ("Error: rc.data.location does not exist - exiting according to rc.exit.on.missing.db setting."); + d.create (); + } } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/CmdShow.cpp b/src/commands/CmdShow.cpp index f214480e4..279f6e3a3 100644 --- a/src/commands/CmdShow.cpp +++ b/src/commands/CmdShow.cpp @@ -140,6 +140,7 @@ int CmdShow::execute (std::string& output) " echo.command" " edit.verbose" " editor" + " exit.on.missing.db" " export.ical.class" " expressions" " extensions" diff --git a/src/recur.cpp b/src/recur.cpp index 1c5cbfc92..446a9a9e0 100644 --- a/src/recur.cpp +++ b/src/recur.cpp @@ -57,7 +57,6 @@ void handleRecurrence () { std::vector tasks; context.tdb.loadPending (tasks); - std::vector modified; // Look at all tasks and find any recurring ones. @@ -66,6 +65,7 @@ void handleRecurrence () { if (t->getStatus () == Task::recurring) { +/* // Generate a list of due dates for this recurring task, regardless of // the mask. std::vector due; @@ -143,6 +143,7 @@ void handleRecurrence () t->set ("mask", mask); context.tdb.update (*t); } +*/ } else modified.push_back (*t); diff --git a/src/text.cpp b/src/text.cpp index daf908018..a32688d7d 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -446,10 +446,7 @@ std::string commify (const std::string& data) std::string lowerCase (const std::string& input) { std::string output = input; - for (int i = 0; i < (int) input.length (); ++i) - if (isupper (input[i])) - output[i] = tolower (input[i]); - + std::transform (output.begin (), output.end (), output.begin (), tolower); return output; } @@ -457,10 +454,7 @@ std::string lowerCase (const std::string& input) std::string upperCase (const std::string& input) { std::string output = input; - for (int i = 0; i < (int) input.length (); ++i) - if (islower (input[i])) - output[i] = toupper (input[i]); - + std::transform (output.begin (), output.end (), output.begin (), toupper); return output; } diff --git a/test/feature.559.t b/test/feature.559.t new file mode 100755 index 000000000..48896dc22 --- /dev/null +++ b/test/feature.559.t @@ -0,0 +1,65 @@ +#! /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 Test::More tests => 7; + +# Create the rc file. +if (open my $fh, '>', 'bug.rc') +{ + print $fh "data.location=.\n", + "exit.on.missing.db=yes\n", + "confirmation=no\n"; + close $fh; + ok (-r 'bug.rc', 'Created bug.rc'); +} + +# Feature 559: rc.exit.on.missing.db should cause exit if rc.data.location is missing. +qx{../src/task rc:bug.rc add foo rc.debug:1}; +my $output = qx{../src/task rc:bug.rc list}; +unlike ($output, qr/Error.+does not exist/, 'No error on extant rc.data.location'); + +$output = qx{../src/task rc:bug.rc rc.data.location=donkey list}; +like ($output, qr/Error.+does not exist/, 'Error on missing rc.data.location'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'completed.data'; +ok (!-r 'completed.data', 'Removed completed.data'); + +unlink 'undo.data'; +ok (!-r 'undo.data', 'Removed undo.data'); + +unlink 'bug.rc'; +ok (!-r 'bug.rc', 'Removed bug.rc'); + +exit 0; +