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).
diff --git a/src/Config.cpp b/src/Config.cpp
index c2cb928fc..de73f42dc 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -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");
diff --git a/src/command.cpp b/src/command.cpp
index 696f51ae0..5cfdc1e00 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -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 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;
diff --git a/src/tests/delete.t b/src/tests/delete.t
index 9f36f517b..d3a34a84c 100755
--- a/src/tests/delete.t
+++ b/src/tests/delete.t
@@ -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');
}
diff --git a/src/tests/recur.t b/src/tests/recur.t
index 7dc5ef410..a6b014787 100755
--- a/src/tests/recur.t
+++ b/src/tests/recur.t
@@ -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')
diff --git a/src/tests/undo.t b/src/tests/undo.t
index ec023b31d..24803cd88 100755
--- a/src/tests/undo.t
+++ b/src/tests/undo.t
@@ -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');
}
diff --git a/src/tests/utf8.t b/src/tests/utf8.t
index bc6e0c6c7..e3e641813 100755
--- a/src/tests/utf8.t
+++ b/src/tests/utf8.t
@@ -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.