Enhancement - #320

- Added feature #320, so the command "task 123" is interpreted as an
  implicit "task info 123" command (thanks to John Florian).
- Modified task man page.
- Added unit tests.
- Updated supported platform lists with F13 and Ubuntu 10.04.
This commit is contained in:
Paul Beckingham 2010-05-30 13:20:39 -04:00
parent b2ad305f23
commit 67ffd07312
5 changed files with 108 additions and 22 deletions

View file

@ -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 ------------------------------

4
NEWS
View file

@ -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

View file

@ -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.

View file

@ -701,7 +701,9 @@ 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 == "")
{
if (parseArgs.size () == 0)
{
// Apply overrides, if any.
std::string defaultCommand = config.get ("default.command");
@ -727,6 +729,16 @@ void Context::parse (
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";
}
}
}
////////////////////////////////////////////////////////////////////////////////

68
src/tests/info.t Executable file
View file

@ -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;