mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 07:57:20 +02:00
Dependencies - add
- Allowed dependencies to be specified when adding a new task.
This commit is contained in:
parent
54cf7e5471
commit
7233fcd05b
1 changed files with 27 additions and 6 deletions
|
@ -99,19 +99,40 @@ int handleAdd (std::string &outs)
|
||||||
!context.task.has ("recur"))
|
!context.task.has ("recur"))
|
||||||
throw std::string ("You cannot specify an until date for a non-recurring task.");
|
throw std::string ("You cannot specify an until date for a non-recurring task.");
|
||||||
|
|
||||||
// TODO Resolve dependencies.
|
// Must load pending to resolve dependencies, and to provide a new ID.
|
||||||
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
|
|
||||||
|
std::vector <Task> all;
|
||||||
|
Filter none;
|
||||||
|
context.tdb.loadPending (all, none);
|
||||||
|
|
||||||
|
// Resolve dependencies.
|
||||||
|
if (context.task.has ("depends"))
|
||||||
|
{
|
||||||
|
// Convert ID to UUID.
|
||||||
|
std::vector <std::string> deps;
|
||||||
|
split (deps, context.task.get ("depends"), ',');
|
||||||
|
|
||||||
|
// Eliminate the ID-based set.
|
||||||
|
context.task.set ("depends", "");
|
||||||
|
|
||||||
|
std::vector <std::string>::iterator i;
|
||||||
|
for (i = deps.begin (); i != deps.end (); i++)
|
||||||
|
{
|
||||||
|
int id = atoi (i->c_str ());
|
||||||
|
if (id < 0)
|
||||||
|
context.task.removeDependency (-id);
|
||||||
|
else
|
||||||
|
context.task.addDependency (id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Only valid tasks can be added.
|
// Only valid tasks can be added.
|
||||||
context.task.validate ();
|
context.task.validate ();
|
||||||
|
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
|
||||||
context.tdb.add (context.task);
|
context.tdb.add (context.task);
|
||||||
|
|
||||||
#ifdef FEATURE_NEW_ID
|
#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 () << std::endl;
|
out << "Created task " << context.tdb.nextId () << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue