diff --git a/ChangeLog b/ChangeLog index 48180bac7..1df489c9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ ------ current release --------------------------- 1.9.2 () + + Added feature #320, so the command "task 123" is interpreted as an + implicit "task info 123" command (thanks to John Florian). ------ old releases ------------------------------ diff --git a/NEWS b/NEWS index 4ed6be80d..e5705a00c 100644 --- a/NEWS +++ b/NEWS @@ -23,8 +23,8 @@ New Features in task 1.9 Task has been built and tested on the following configurations: * OS X 10.6 Snow Leopard and 10.5 Leopard - * Fedora 12 Constantine and 11 Leonidas - * Ubuntu 9.10 Karmic Koala and 9.04 Jaunty Jackalope + * Fedora 13 Goddard, 12 Constantine and 11 Leonidas + * Ubuntu 10.04 Lucid Lynx, 9.10 Karmic Koala and 9.04 Jaunty Jackalope * Debian Sid * Slackware 12.2 * Arch Linux diff --git a/doc/man/task.1 b/doc/man/task.1 index 00c4a370d..153a01425 100644 --- a/doc/man/task.1 +++ b/doc/man/task.1 @@ -41,6 +41,10 @@ Performs one substitution on task description and annotation for fixing mistakes .B ID /from/to/g Performs all substitutions on task description and annotation for fixing mistakes. +.TP +.B ID +With an ID but no specific command, task runs the "info" command. + .TP .B edit ID Launches an editor to let you modify all aspects of a task directly. diff --git a/src/Context.cpp b/src/Context.cpp index 3f64d66e1..2bf963d39 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -701,31 +701,43 @@ void Context::parse ( // If no command was specified, and there were no command line arguments // then invoke the default command. - if (parseCmd.command == "" && parseArgs.size () == 0) + if (parseCmd.command == "") { - // Apply overrides, if any. - std::string defaultCommand = config.get ("default.command"); - if (defaultCommand != "") + if (parseArgs.size () == 0) { - // Add on the overrides. - defaultCommand += " " + file_override + " " + var_overrides; + // Apply overrides, if any. + std::string defaultCommand = config.get ("default.command"); + if (defaultCommand != "") + { + // Add on the overrides. + defaultCommand += " " + file_override + " " + var_overrides; - // Stuff the command line. - args.clear (); - split (args, defaultCommand, ' '); - header ("[task " + trim (defaultCommand) + "]"); + // Stuff the command line. + args.clear (); + split (args, defaultCommand, ' '); + header ("[task " + trim (defaultCommand) + "]"); - // Reinitialize the context and recurse. - file_override = ""; - var_overrides = ""; - footnotes.clear (); - initialize (); - parse (args, cmd, task, sequence, subst, filter); + // Reinitialize the context and recurse. + file_override = ""; + var_overrides = ""; + footnotes.clear (); + initialize (); + parse (args, cmd, task, sequence, subst, filter); + } + else + throw stringtable.get ( + CMD_MISSING, + "You must specify a command, or a task ID to modify"); + } + + // If the command "task 123" is entered, then the actual command is assumed + // to be "info". + else if (parseTask.id != 0 || + parseSequence.size () != 0) + { + std::cout << "No command - assuming 'info'." << std::endl; + parseCmd.command = "info"; } - else - throw stringtable.get ( - CMD_MISSING, - "You must specify a command, or a task ID to modify"); } } diff --git a/src/tests/info.t b/src/tests/info.t new file mode 100755 index 000000000..024e05356 --- /dev/null +++ b/src/tests/info.t @@ -0,0 +1,68 @@ +#! /usr/bin/perl +################################################################################ +## task - a command line task list manager. +## +## Copyright 2006 - 2010, 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 +## +################################################################################ + +use strict; +use warnings; +use Test::More tests => 10; + +# Create the rc file. +if (open my $fh, '>', 'info.rc') +{ + print $fh "data.location=.\n", + "confirmation=off\n"; + close $fh; + ok (-r 'info.rc', 'Created info.rc'); +} + +# Test the add command. +qx{../task rc:info.rc add test one}; +qx{../task rc:info.rc add test two}; +qx{../task rc:info.rc add test three}; + +my $output = qx{../task rc:info.rc 1}; +like ($output, qr/Description\s+test one\n/, 'single auto-info one'); +unlike ($output, qr/Description\s+test two\n/, 'single auto-info !two'); +unlike ($output, qr/Description\s+test three\n/, 'single auto-info !three'); + +$output = qx{../task rc:info.rc 1-2}; +like ($output, qr/Description\s+test one\n/, 'single auto-info one'); +like ($output, qr/Description\s+test two\n/, 'single auto-info two'); +unlike ($output, qr/Description\s+test three\n/, 'single auto-info !three'); + +# Cleanup. +unlink 'pending.data'; +ok (!-r 'pending.data', 'Removed pending.data'); + +unlink 'undo.data'; +ok (!-r 'undo.data', 'Removed undo.data'); + +unlink 'info.rc'; +ok (!-r 'info.rc', 'Removed info.rc'); + +exit 0; +