mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-04 10:37:19 +02:00
Task Validation
- Cleaned up the 'import' command due to the new validation code.
This commit is contained in:
parent
12e1a30d2f
commit
641d4356c4
1 changed files with 5 additions and 5 deletions
|
@ -93,6 +93,9 @@ int CmdImport::execute (std::string& output)
|
||||||
trim (*line), ","),
|
trim (*line), ","),
|
||||||
"]"),
|
"]"),
|
||||||
"[");
|
"[");
|
||||||
|
// Skip blanks. May be caused by the trim calls above.
|
||||||
|
if (! object.length ())
|
||||||
|
continue;
|
||||||
|
|
||||||
// Parse the whole thing.
|
// Parse the whole thing.
|
||||||
json::value* root = json::parse (object);
|
json::value* root = json::parse (object);
|
||||||
|
@ -100,7 +103,6 @@ int CmdImport::execute (std::string& output)
|
||||||
{
|
{
|
||||||
json::object* root_obj = (json::object*)root;
|
json::object* root_obj = (json::object*)root;
|
||||||
Task task;
|
Task task;
|
||||||
task.set ("uuid", uuid ());
|
|
||||||
|
|
||||||
// For each object element...
|
// For each object element...
|
||||||
json_object_iter i;
|
json_object_iter i;
|
||||||
|
@ -192,15 +194,13 @@ int CmdImport::execute (std::string& output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task.validate ();
|
context.tdb2.add (task);
|
||||||
|
++count;
|
||||||
std::cout << " "
|
std::cout << " "
|
||||||
<< task.get ("uuid")
|
<< task.get ("uuid")
|
||||||
<< " "
|
<< " "
|
||||||
<< task.get ("description")
|
<< task.get ("description")
|
||||||
<< "\n";
|
<< "\n";
|
||||||
context.tdb2.add (task);
|
|
||||||
++count;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw std::string ("Not a JSON object: ") + *line;
|
throw std::string ("Not a JSON object: ") + *line;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue