- Combined ::findFileOverride and ::findConfigOverride into ::findOverride.
- Made ::findBinary public, and corrected comment.
This commit is contained in:
Paul Beckingham 2014-04-20 09:26:01 -04:00
parent 13c0efb178
commit 6f948826a7
4 changed files with 13 additions and 35 deletions

View file

@ -127,7 +127,6 @@ Tree* A3t::tree ()
////////////////////////////////////////////////////////////////////////////////
Tree* A3t::parse ()
{
findBinary ();
findTerminator ();
findSubstitution ();
findPattern ();
@ -176,8 +175,7 @@ bool A3t::canonicalize (
}
////////////////////////////////////////////////////////////////////////////////
// Walk the top-level tree branches, looking for the first raw value that
// autoCompletes to a valid command/report.
// Locate and tag the binary.
void A3t::findBinary ()
{
if (_tree->_branches.size () >= 1)
@ -292,8 +290,9 @@ void A3t::findCommand ()
}
////////////////////////////////////////////////////////////////////////////////
// Process 'rc:<file>' command line override.
void A3t::findFileOverride ()
// rc:<file>
// rc.<name>[:=]<value>
void A3t::findOverrides ()
{
std::vector <Tree*>::iterator i;
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
@ -313,26 +312,7 @@ void A3t::findFileOverride ()
(*i)->tag ("RC");
(*i)->attribute ("file", arg.substr (3));
}
}
}
////////////////////////////////////////////////////////////////////////////////
// rc.<name>[:=]<value>
void A3t::findConfigOverride ()
{
std::vector <Tree*>::iterator i;
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
{
// Parser override operator.
if ((*i)->attribute ("raw") == "--")
break;
// Skip known args.
if (! (*i)->hasTag ("?"))
continue;
std::string arg = (*i)->attribute ("raw");
if (arg.find ("rc.") == 0)
else if (arg.find ("rc.") == 0)
{
std::string::size_type sep = arg.find ('=', 3);
if (sep == std::string::npos)

View file

@ -44,8 +44,8 @@ public:
void entity (const std::string&, const std::string&);
bool canonicalize (std::string&, const std::string&, const std::string&) const;
void findFileOverride ();
void findConfigOverride ();
void findBinary ();
void findOverrides ();
void findCommand ();
void findIdSequence ();
void findUUIDList ();
@ -57,7 +57,6 @@ public:
Tree* capture_first (const std::string&);
private:
void findBinary ();
void findTerminator ();
void findPattern ();
void findSubstitution ();

View file

@ -114,8 +114,7 @@ int Context::initialize (int argc, const char** argv)
// Process 'rc:<file>' command line override, and remove the argument from the
// Context::a3.
a3.categorize ();
a3t.findFileOverride (); // rc:<file>
a3t.findOverrides (); // rc:<file> rc.<name>:<value>
a3t.get_overrides (home_dir, rc_file); // <-- <file>
// TASKRC environment variable overrides the command line.
@ -133,7 +132,6 @@ int Context::initialize (int argc, const char** argv)
// The data location, Context::data_dir, is determined from the assumed
// location (~/.task), or set by data.location in the config file, or
// overridden by rc.data.location on the command line.
a3t.findConfigOverride (); // rc.<name>[:=]<value>
a3t.get_data_location (data_dir); // <-- rc.data.location=<location>
override = getenv ("TASKDATA");
@ -197,6 +195,7 @@ int Context::initialize (int argc, const char** argv)
a3t.entity ("operator", *op);
// Now the entities are loaded, parsing may resume.
a3t.findBinary (); // <task|tw|t|cal|calendar>
a3t.findCommand (); // <cmd>
a3t.findUUIDList (); // <uuid> Before findIdSequence
a3t.findIdSequence (); // <id>
@ -220,8 +219,8 @@ int Context::initialize (int argc, const char** argv)
// TODO Uncommenting this breaks unit tests because of the errors it
// generates.
//Tree* parseTree = NULL;
Tree* parseTree = a3t.parse ();
Tree* parseTree = NULL;
//Tree* parseTree = a3t.parse ();
// Initialize the command line parser.
if (parseTree && config.getBoolean ("debug"))

View file

@ -38,8 +38,7 @@ int main (int argc, const char** argv)
A3t a3t;
a3t.initialize (argc, argv);
a3t.append_stdin ();
a3t.findFileOverride ();
a3t.findConfigOverride ();
a3t.findOverrides ();
Alias alias;
alias.resolve (a3t.tree ());
@ -147,6 +146,7 @@ int main (int argc, const char** argv)
a3t.entity ("operator", "^");
a3t.entity ("operator", "!");
a3t.findBinary ();
a3t.findCommand ();
a3t.findUUIDList ();
a3t.findIdSequence ();