mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Feature #514
- Added feature #514, which allows duplication of tasks based on a generalized filter, rather than just IDs (thanks to Peter De Poorter).
This commit is contained in:
parent
f0d2af2651
commit
9b3f9ee4ff
3 changed files with 38 additions and 46 deletions
|
@ -43,6 +43,8 @@
|
||||||
+ Added feature #330, which supports the 'inverse' color attribute.
|
+ Added feature #330, which supports the 'inverse' color attribute.
|
||||||
+ Added feature #340, which implements new color rules 'color.completed' and
|
+ Added feature #340, which implements new color rules 'color.completed' and
|
||||||
'color.deleted'.
|
'color.deleted'.
|
||||||
|
+ Added feature #422, which allows task modifications during 'done', 'delete',
|
||||||
|
'start' and 'stop' commands.
|
||||||
+ Added feature #479, which enables filtering for the 'calendar' command.
|
+ Added feature #479, which enables filtering for the 'calendar' command.
|
||||||
+ Added feature #496, which allows rc.default.command to be supplemented with
|
+ Added feature #496, which allows rc.default.command to be supplemented with
|
||||||
a filter, so that 'task project:Home' applies the project filter to the
|
a filter, so that 'task project:Home' applies the project filter to the
|
||||||
|
@ -50,6 +52,8 @@
|
||||||
+ Added feature #507, which provides an alternative mechanism for inverting
|
+ Added feature #507, which provides an alternative mechanism for inverting
|
||||||
attribute modifiers, in the form of new algebraic filters (thanks to Michelle
|
attribute modifiers, in the form of new algebraic filters (thanks to Michelle
|
||||||
Crane).
|
Crane).
|
||||||
|
+ Added feature #514, which allows duplication of tasks based on a generalized
|
||||||
|
filter, rather than just IDs (thanks to Peter De Poorter).
|
||||||
+ Added feature #523 & #659, adding 'status' as a reportable field (thanks to
|
+ Added feature #523 & #659, adding 'status' as a reportable field (thanks to
|
||||||
Peter De Poorter and Bryce Harrington).
|
Peter De Poorter and Bryce Harrington).
|
||||||
+ Added feature #545, #610, #611, #646, which support complex aliases.
|
+ Added feature #545, #610, #611, #646, which support complex aliases.
|
||||||
|
|
2
NEWS
2
NEWS
|
@ -21,6 +21,8 @@ New Features in taskwarrior 2.0.0
|
||||||
- New 'reports' command that lists reports and their descriptions.
|
- New 'reports' command that lists reports and their descriptions.
|
||||||
- New complex aliases.
|
- New complex aliases.
|
||||||
- Filtering now available on most read-only commands.
|
- Filtering now available on most read-only commands.
|
||||||
|
- The done, delete, start and stop commands now allow modification to the
|
||||||
|
task and annotations.
|
||||||
|
|
||||||
Please refer to the ChangeLog file for full details. There are too many to
|
Please refer to the ChangeLog file for full details. There are too many to
|
||||||
list here.
|
list here.
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
#include <i18n.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <CmdDuplicate.h>
|
#include <CmdDuplicate.h>
|
||||||
|
|
||||||
|
@ -37,9 +38,9 @@ extern Context context;
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CmdDuplicate::CmdDuplicate ()
|
CmdDuplicate::CmdDuplicate ()
|
||||||
{
|
{
|
||||||
_keyword = "dulicate";
|
_keyword = "duplicate";
|
||||||
_usage = "task duplicate ID [tags] [attrs] [desc...]";
|
_usage = "task <filter> duplicate [<modifications>]";
|
||||||
_description = "Duplicates the specified task, and allows modifications.";
|
_description = "Duplicates the specified tasks, and allows modifications.";
|
||||||
_read_only = false;
|
_read_only = false;
|
||||||
_displays_id = false;
|
_displays_id = false;
|
||||||
}
|
}
|
||||||
|
@ -48,31 +49,35 @@ CmdDuplicate::CmdDuplicate ()
|
||||||
int CmdDuplicate::execute (std::string& output)
|
int CmdDuplicate::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
/*
|
|
||||||
std::stringstream out;
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
std::stringstream out;
|
||||||
|
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
Filter filter;
|
context.tdb.loadPending (tasks);
|
||||||
context.tdb.loadPending (tasks, filter);
|
|
||||||
|
|
||||||
// Filter sequence.
|
// Apply filter.
|
||||||
context.filter.applySequence (tasks, context.sequence);
|
std::vector <Task> filtered;
|
||||||
if (tasks.size () == 0)
|
filter (tasks, filtered);
|
||||||
|
|
||||||
|
if (filtered.size () == 0)
|
||||||
{
|
{
|
||||||
context.footnote ("No tasks specified.");
|
context.footnote (STRING_FEEDBACK_NO_TASKS_SP);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply the command line modifications to the completed task.
|
||||||
|
Arguments modifications = context.args.extract_modifications ();
|
||||||
|
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++task)
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
{
|
{
|
||||||
Task dup (*task);
|
Task dup (*task);
|
||||||
dup.set ("uuid", uuid ()); // Needs a new UUID.
|
dup.set ("uuid", uuid ()); // Needs a new UUID.
|
||||||
dup.setStatus (Task::pending);
|
dup.setStatus (Task::pending); // Does not inherit status.
|
||||||
dup.remove ("start"); // Does not inherit start date.
|
dup.remove ("start"); // Does not inherit start date.
|
||||||
dup.remove ("end"); // Does not inherit end date.
|
dup.remove ("end"); // Does not inherit end date.
|
||||||
|
dup.remove ("entry"); // Does not inherit entry date.
|
||||||
|
|
||||||
// Recurring tasks are duplicated and downgraded to regular tasks.
|
// Recurring tasks are duplicated and downgraded to regular tasks.
|
||||||
if (task->getStatus () == Task::recurring)
|
if (task->getStatus () == Task::recurring)
|
||||||
|
@ -85,24 +90,17 @@ int CmdDuplicate::execute (std::string& output)
|
||||||
|
|
||||||
out << "Note: task "
|
out << "Note: task "
|
||||||
<< task->id
|
<< task->id
|
||||||
<< " was a recurring task. The new task is not.\n";
|
<< " was a recurring task. The duplicate task is not.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply deltas.
|
modify_task_annotate (dup, modifications);
|
||||||
deltaDescription (dup);
|
apply_defaults (dup);
|
||||||
deltaTags (dup);
|
|
||||||
deltaAttributes (dup);
|
|
||||||
deltaSubstitutions (dup);
|
|
||||||
|
|
||||||
// A New task needs a new entry time.
|
|
||||||
char entryTime[16];
|
|
||||||
sprintf (entryTime, "%u", (unsigned int) time (NULL));
|
|
||||||
dup.set ("entry", entryTime);
|
|
||||||
|
|
||||||
// Only allow valid tasks.
|
// Only allow valid tasks.
|
||||||
dup.validate ();
|
dup.validate ();
|
||||||
|
|
||||||
context.tdb.add (dup);
|
context.tdb.add (dup);
|
||||||
|
++count;
|
||||||
|
|
||||||
if (context.config.getBoolean ("echo.command"))
|
if (context.config.getBoolean ("echo.command"))
|
||||||
out << "Duplicated "
|
out << "Duplicated "
|
||||||
|
@ -111,32 +109,20 @@ int CmdDuplicate::execute (std::string& output)
|
||||||
<< task->get ("description")
|
<< task->get ("description")
|
||||||
<< "'.\n";
|
<< "'.\n";
|
||||||
|
|
||||||
|
// TODO This should be a call in to feedback.cpp.
|
||||||
|
out << format (STRING_CMD_ADD_FEEDBACK, context.tdb.nextId ()) + "\n";
|
||||||
|
|
||||||
context.footnote (onProjectChange (dup));
|
context.footnote (onProjectChange (dup));
|
||||||
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tasks.size () == 0)
|
|
||||||
{
|
|
||||||
out << "No matches.\n";
|
|
||||||
rc = 1;
|
|
||||||
}
|
|
||||||
else if (context.config.getBoolean ("echo.command"))
|
|
||||||
{
|
|
||||||
#ifdef FEATURE_NEW_ID
|
|
||||||
// All this, just for an id number.
|
|
||||||
std::vector <Task> all;
|
|
||||||
Filter none;
|
|
||||||
context.tdb.loadPending (all, none);
|
|
||||||
out << "Created task " << context.tdb.nextId () << ".\n";
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count)
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
|
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
// TODO Add count summary, like the 'done' command.
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue