- TW-1300 _get could use return codes (thanks to Scott Kostyshak).
This commit is contained in:
Paul Beckingham 2014-04-12 13:32:35 -04:00
parent 32272addd0
commit 501194abfa
6 changed files with 107 additions and 5 deletions

View file

@ -157,9 +157,9 @@ const std::string DOM::get (const std::string& name, const Task& task)
std::string canonical;
// <attr>
if (name == "id") return format (task.id);
else if (name == "urgency") return format (task.urgency_c ());
else if (A3::is_attribute (name, canonical)) return task.get (canonical);
if (task.size () && name == "id") return format (task.id);
else if (task.size () && name == "urgency") return format (task.urgency_c ());
else if (task.size () && A3::is_attribute (name, canonical)) return task.get (canonical);
// <id>.<name>
if (n.getInt (id))

View file

@ -52,17 +52,23 @@ int CmdGet::execute (std::string& output)
if (words.size () == 0)
throw std::string (STRING_CMD_GET_NO_DOM);
bool found = false;
std::vector <std::string> results;
std::vector <std::string>::iterator word;
for (word = words.begin (); word != words.end (); ++word)
{
Task t;
results.push_back (context.dom.get (*word, t));
std::string result = context.dom.get (*word, t);
results.push_back (result);
if (result != "" &&
result != *word)
found = true;
}
join (output, " ", results);
output += "\n";
return 0;
return found ? 0 : 1;
}
////////////////////////////////////////////////////////////////////////////////