mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Feature
- Allow UUIDs and IDs range when modifying task dependencies. - Update man page. - Add unit tests. - Fatorize code when adding and removing dependencies in Task.cpp.
This commit is contained in:
parent
5ffb65b5ac
commit
1364202d30
5 changed files with 72 additions and 32 deletions
|
@ -478,10 +478,10 @@ void Command::modify_task (
|
|||
}
|
||||
else
|
||||
{
|
||||
// Dependencies must be resolved to UUIDs.
|
||||
// Dependencies are used as IDs.
|
||||
if (name == "depends")
|
||||
{
|
||||
// Convert ID to UUID.
|
||||
// Parse IDs
|
||||
std::vector <std::string> deps;
|
||||
split (deps, value, ',');
|
||||
|
||||
|
@ -489,11 +489,31 @@ void Command::modify_task (
|
|||
std::vector <std::string>::iterator i;
|
||||
for (i = deps.begin (); i != deps.end (); i++)
|
||||
{
|
||||
int id = strtol (i->c_str (), NULL, 10);
|
||||
if (id < 0)
|
||||
task.removeDependency (-id);
|
||||
bool removal = false;
|
||||
std::string& dep = *i;
|
||||
|
||||
if (dep[0] == '-')
|
||||
{
|
||||
removal = true;
|
||||
dep = i->substr(1, std::string::npos);
|
||||
}
|
||||
|
||||
std::vector <int> ids;
|
||||
// Crude UUID check
|
||||
if (dep.length () == 36)
|
||||
{
|
||||
int id = context.tdb2.pending.id (dep);
|
||||
ids.push_back (id);
|
||||
}
|
||||
else
|
||||
task.addDependency (id);
|
||||
A3::extract_id (dep, ids);
|
||||
|
||||
std::vector <int>::iterator id;
|
||||
for (id = ids.begin (); id != ids.end(); id++)
|
||||
if (removal)
|
||||
task.removeDependency (*id);
|
||||
else
|
||||
task.addDependency (*id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue