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

@ -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");
}
}

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;