Enhancement - added echo of id, description

- Added an echo of the ID and description of the task for the start,
  stop, do, undo, delete and undelete commands.  Thanks to Bruce
  Dillahunty.
- Updated documentation.
- Added "echo.command=no" to delete.t, undo.t because the default
  value is "yes", which breaks tests.
- Fixed syntax errors in utf8.t
- Corrected expected number of tests in recur.t
This commit is contained in:
Paul Beckingham 2009-03-22 23:34:17 -04:00
parent ca933d7f39
commit f790df24c5
9 changed files with 69 additions and 16 deletions

View file

@ -9,6 +9,9 @@
+ UTF8 text is now supported in task project names, tags and descriptions.
+ Fixed bug that caused the y/n confirmation on task deletion to ignore the
Enter key and fail to re-prompt (thanks to Bruce Dillahunty).
+ Added support for the "echo.command" configuration variable that displays
the task affected by the start, stop, do, undo, delete and undelete
commands (thanks to Bruce Dillahunty).
------ old releases ------------------------------

View file

@ -58,6 +58,13 @@
confirmation before deleting a task.
</dd>
<dt>echo.command</dt>
<dd>
May be "yes" or "no", and causes task to display the ID and
description of any task when you run the start, stop, do, undo,
delete and undelete commands. The default value is "yes".
</dd>
<dt>nag</dt>
<dd>
This may be a string of text, or blank. It is used as a prompt

View file

@ -105,6 +105,9 @@
<li>UTF8 text is now supported in task project names, tags and descriptions.
<li>Fixed bug that caused the y/n confirmation on task deletion to ignore the
Enter key and fail to re-prompt (thanks to Bruce Dillahunty).
<li>Added support for the "echo.command" configuration variable that displays
the task affected by the start, stop, do, undo, delete and undelete
commands (thanks to Bruce Dillahunty).
</ul>
<p>

View file

@ -140,6 +140,7 @@ void Config::createDefault (const std::string& home)
{
fprintf (out, "data.location=%s\n", dataDir.c_str ());
fprintf (out, "confirmation=yes\n");
fprintf (out, "echo.command=yes\n");
fprintf (out, "next=2\n");
fprintf (out, "dateformat=m/d/Y\n");
fprintf (out, "#monthsperline=2\n");

View file

@ -432,6 +432,8 @@ std::string handleVersion (Config& conf)
////////////////////////////////////////////////////////////////////////////////
std::string handleDelete (TDB& tdb, T& task, Config& conf)
{
std::stringstream out;
if (conf.get ("confirmation") != "yes" || confirm ("Permanently delete task?"))
{
std::vector <T> all;
@ -450,11 +452,19 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf)
// Scan all pending tasks for siblings of this task, and the parent
// itself, and delete them.
foreach (sibling, all)
{
if (sibling->getAttribute ("parent") == parent ||
sibling->getUUID () == parent)
{
tdb.deleteT (*sibling);
return std::string ("");
if (conf.get ("echo.command", true))
out << "Deleting recurring task "
<< sibling->getId ()
<< " "
<< sibling->getDescription ()
<< std::endl;
}
}
}
else
{
@ -462,20 +472,32 @@ std::string handleDelete (TDB& tdb, T& task, Config& conf)
t->setStatus (T::deleted);
updateRecurrenceMask (tdb, all, *t);
tdb.deleteT (*t);
return std::string ("");
out << "Deleting recurring task "
<< t->getId ()
<< " "
<< t->getDescription ()
<< std::endl;
}
}
else
{
tdb.deleteT (*t);
if (conf.get ("echo.command", true))
out << "Deleting task "
<< t->getId ()
<< " "
<< t->getDescription ()
<< std::endl;
}
break; // No point continuing the loop.
}
}
}
else
return std::string ("Task not deleted.\n");
out << "Task not deleted." << std::endl;
return std::string ("");
return out.str ();
}
////////////////////////////////////////////////////////////////////////////////
@ -490,6 +512,7 @@ std::string handleStart (TDB& tdb, T& task, Config& conf)
if (it->getId () == task.getId ())
{
T original (*it);
std::stringstream out;
if (original.getAttribute ("start") == "")
{
@ -500,15 +523,20 @@ std::string handleStart (TDB& tdb, T& task, Config& conf)
original.setId (task.getId ());
tdb.modifyT (original);
if (conf.get ("echo.command", true))
out << "Started "
<< original.getId ()
<< " "
<< original.getDescription ()
<< std::endl;
nag (tdb, task, conf);
return std::string ("");
}
else
{
std::stringstream out;
out << "Task " << task.getId () << " already started." << std::endl;
return out.str ();
}
return out.str ();
}
}
@ -528,6 +556,7 @@ std::string handleStop (TDB& tdb, T& task, Config& conf)
if (it->getId () == task.getId ())
{
T original (*it);
std::stringstream out;
if (original.getAttribute ("start") != "")
{
@ -535,14 +564,15 @@ std::string handleStop (TDB& tdb, T& task, Config& conf)
original.setId (task.getId ());
tdb.modifyT (original);
return std::string ("");
if (conf.get ("echo.command", true))
out << "Stopped " << original.getId () << " " << original.getDescription () << std::endl;
}
else
{
std::stringstream out;
out << "Task " << task.getId () << " not started." << std::endl;
return out.str ();
}
return out.str ();
}
}
@ -565,6 +595,13 @@ std::string handleDone (TDB& tdb, T& task, Config& conf)
{
if (t->getId () == task.getId ())
{
if (conf.get ("echo.command", true))
out << "Completed "
<< t->getId ()
<< " "
<< t->getDescription ()
<< std::endl;
t->setStatus (T::completed);
updateRecurrenceMask (tdb, all, *t);
break;

View file

@ -33,7 +33,8 @@ use Test::More tests => 16;
# Create the rc file.
if (open my $fh, '>', 'undelete.rc')
{
print $fh "data.location=.\n";
print $fh "data.location=.\n",
"echo.command=no\n";
close $fh;
ok (-r 'undelete.rc', 'Created undelete.rc');
}

View file

@ -28,7 +28,7 @@
use strict;
use warnings;
use Test::More tests => 6;
use Test::More tests => 5;
# Create the rc file.
if (open my $fh, '>', 'recur.rc')

View file

@ -33,7 +33,8 @@ use Test::More tests => 15;
# Create the rc file.
if (open my $fh, '>', 'undo.rc')
{
print $fh "data.location=.\n";
print $fh "data.location=.\n",
"echo.command=no\n";
close $fh;
ok (-r 'undo.rc', 'Created undo.rc');
}

View file

@ -62,11 +62,11 @@ diag ($output);
like ($output, qr/17/, 'all 17 tasks shown');
qx{../task rc:utf8.rc add project:Çirçös utf8 in project};
my $output = qx{../task rc:utf8.rc ls project:Çirçös};
$output = qx{../task rc:utf8.rc ls project:Çirçös};
like ($output, qr/Çirçös.+utf8 in project/, 'utf8 in project works');
qx{../task rc:utf8.rc add utf8 in tag +☺};
my $output = qx{../task rc:utf8.rc ls +☺};
$output = qx{../task rc:utf8.rc ls +☺};
like ($output, qr/utf8 in tag/, 'utf8 in tag works');
# Cleanup.