- Converted DOM and unit test from Parser to CLI.
This commit is contained in:
Paul Beckingham 2014-10-25 22:55:31 -04:00
parent efb84b20bf
commit 283a1aa8ef
2 changed files with 5 additions and 13 deletions

View file

@ -109,16 +109,8 @@ bool DOM::get (const std::string& name, Variant& value)
} }
else if (name == "context.args") else if (name == "context.args")
{ {
std::string commandLine = ""; std::string commandLine;
std::vector <Tree*>::iterator i; join (commandLine, " ", context.cli._original_args);
for (i = context.parser.tree ()->_branches.begin (); i != context.parser.tree ()->_branches.end (); ++i)
{
if (commandLine != "")
commandLine += " ";
commandLine += (*i)->attribute ("raw");
}
value = Variant (commandLine); value = Variant (commandLine);
return true; return true;
} }
@ -243,7 +235,7 @@ bool DOM::get (const std::string& name, const Task& task, Variant& value)
if (elements.size () == 1) if (elements.size () == 1)
{ {
std::string canonical; std::string canonical;
if (task.size () && context.parser.canonicalize (canonical, "attribute", name)) if (task.size () && context.cli.canonicalize (canonical, "attribute", name))
{ {
Column* column = context.columns[canonical]; Column* column = context.columns[canonical];
if (column) if (column)
@ -308,7 +300,7 @@ bool DOM::get (const std::string& name, const Task& task, Variant& value)
} }
std::string canonical; std::string canonical;
if (context.parser.canonicalize (canonical, "attribute", elements[1])) if (context.cli.canonicalize (canonical, "attribute", elements[1]))
{ {
if (elements.size () == 2) if (elements.size () == 2)
{ {

View file

@ -47,7 +47,7 @@ int main (int argc, char** argv)
{ {
// Prime the pump. // Prime the pump.
const char* fake_argv[] = {"task"}; const char* fake_argv[] = {"task"};
context.parser.initialize (1, fake_argv); context.cli.initialize (1, fake_argv);
context.program = "task"; context.program = "task";
context.config.set ("name", "value"); context.config.set ("name", "value");