mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 22:47:20 +02:00
A3t
- Combined ::findFileOverride and ::findConfigOverride into ::findOverride. - Made ::findBinary public, and corrected comment.
This commit is contained in:
parent
13c0efb178
commit
6f948826a7
4 changed files with 13 additions and 35 deletions
30
src/A3t.cpp
30
src/A3t.cpp
|
@ -127,7 +127,6 @@ Tree* A3t::tree ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Tree* A3t::parse ()
|
Tree* A3t::parse ()
|
||||||
{
|
{
|
||||||
findBinary ();
|
|
||||||
findTerminator ();
|
findTerminator ();
|
||||||
findSubstitution ();
|
findSubstitution ();
|
||||||
findPattern ();
|
findPattern ();
|
||||||
|
@ -176,8 +175,7 @@ bool A3t::canonicalize (
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Walk the top-level tree branches, looking for the first raw value that
|
// Locate and tag the binary.
|
||||||
// autoCompletes to a valid command/report.
|
|
||||||
void A3t::findBinary ()
|
void A3t::findBinary ()
|
||||||
{
|
{
|
||||||
if (_tree->_branches.size () >= 1)
|
if (_tree->_branches.size () >= 1)
|
||||||
|
@ -292,8 +290,9 @@ void A3t::findCommand ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Process 'rc:<file>' command line override.
|
// rc:<file>
|
||||||
void A3t::findFileOverride ()
|
// rc.<name>[:=]<value>
|
||||||
|
void A3t::findOverrides ()
|
||||||
{
|
{
|
||||||
std::vector <Tree*>::iterator i;
|
std::vector <Tree*>::iterator i;
|
||||||
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
|
||||||
|
@ -313,26 +312,7 @@ void A3t::findFileOverride ()
|
||||||
(*i)->tag ("RC");
|
(*i)->tag ("RC");
|
||||||
(*i)->attribute ("file", arg.substr (3));
|
(*i)->attribute ("file", arg.substr (3));
|
||||||
}
|
}
|
||||||
}
|
else if (arg.find ("rc.") == 0)
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// 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)
|
|
||||||
{
|
{
|
||||||
std::string::size_type sep = arg.find ('=', 3);
|
std::string::size_type sep = arg.find ('=', 3);
|
||||||
if (sep == std::string::npos)
|
if (sep == std::string::npos)
|
||||||
|
|
|
@ -44,8 +44,8 @@ public:
|
||||||
void entity (const std::string&, const std::string&);
|
void entity (const std::string&, const std::string&);
|
||||||
bool canonicalize (std::string&, const std::string&, const std::string&) const;
|
bool canonicalize (std::string&, const std::string&, const std::string&) const;
|
||||||
|
|
||||||
void findFileOverride ();
|
void findBinary ();
|
||||||
void findConfigOverride ();
|
void findOverrides ();
|
||||||
void findCommand ();
|
void findCommand ();
|
||||||
void findIdSequence ();
|
void findIdSequence ();
|
||||||
void findUUIDList ();
|
void findUUIDList ();
|
||||||
|
@ -57,7 +57,6 @@ public:
|
||||||
Tree* capture_first (const std::string&);
|
Tree* capture_first (const std::string&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void findBinary ();
|
|
||||||
void findTerminator ();
|
void findTerminator ();
|
||||||
void findPattern ();
|
void findPattern ();
|
||||||
void findSubstitution ();
|
void findSubstitution ();
|
||||||
|
|
|
@ -114,8 +114,7 @@ int Context::initialize (int argc, const char** argv)
|
||||||
// Process 'rc:<file>' command line override, and remove the argument from the
|
// Process 'rc:<file>' command line override, and remove the argument from the
|
||||||
// Context::a3.
|
// Context::a3.
|
||||||
a3.categorize ();
|
a3.categorize ();
|
||||||
|
a3t.findOverrides (); // rc:<file> rc.<name>:<value>
|
||||||
a3t.findFileOverride (); // rc:<file>
|
|
||||||
a3t.get_overrides (home_dir, rc_file); // <-- <file>
|
a3t.get_overrides (home_dir, rc_file); // <-- <file>
|
||||||
|
|
||||||
// TASKRC environment variable overrides the command line.
|
// 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
|
// The data location, Context::data_dir, is determined from the assumed
|
||||||
// location (~/.task), or set by data.location in the config file, or
|
// location (~/.task), or set by data.location in the config file, or
|
||||||
// overridden by rc.data.location on the command line.
|
// overridden by rc.data.location on the command line.
|
||||||
a3t.findConfigOverride (); // rc.<name>[:=]<value>
|
|
||||||
a3t.get_data_location (data_dir); // <-- rc.data.location=<location>
|
a3t.get_data_location (data_dir); // <-- rc.data.location=<location>
|
||||||
|
|
||||||
override = getenv ("TASKDATA");
|
override = getenv ("TASKDATA");
|
||||||
|
@ -197,6 +195,7 @@ int Context::initialize (int argc, const char** argv)
|
||||||
a3t.entity ("operator", *op);
|
a3t.entity ("operator", *op);
|
||||||
|
|
||||||
// Now the entities are loaded, parsing may resume.
|
// Now the entities are loaded, parsing may resume.
|
||||||
|
a3t.findBinary (); // <task|tw|t|cal|calendar>
|
||||||
a3t.findCommand (); // <cmd>
|
a3t.findCommand (); // <cmd>
|
||||||
a3t.findUUIDList (); // <uuid> Before findIdSequence
|
a3t.findUUIDList (); // <uuid> Before findIdSequence
|
||||||
a3t.findIdSequence (); // <id>
|
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
|
// TODO Uncommenting this breaks unit tests because of the errors it
|
||||||
// generates.
|
// generates.
|
||||||
//Tree* parseTree = NULL;
|
Tree* parseTree = NULL;
|
||||||
Tree* parseTree = a3t.parse ();
|
//Tree* parseTree = a3t.parse ();
|
||||||
|
|
||||||
// Initialize the command line parser.
|
// Initialize the command line parser.
|
||||||
if (parseTree && config.getBoolean ("debug"))
|
if (parseTree && config.getBoolean ("debug"))
|
||||||
|
|
|
@ -38,8 +38,7 @@ int main (int argc, const char** argv)
|
||||||
A3t a3t;
|
A3t a3t;
|
||||||
a3t.initialize (argc, argv);
|
a3t.initialize (argc, argv);
|
||||||
a3t.append_stdin ();
|
a3t.append_stdin ();
|
||||||
a3t.findFileOverride ();
|
a3t.findOverrides ();
|
||||||
a3t.findConfigOverride ();
|
|
||||||
|
|
||||||
Alias alias;
|
Alias alias;
|
||||||
alias.resolve (a3t.tree ());
|
alias.resolve (a3t.tree ());
|
||||||
|
@ -147,6 +146,7 @@ int main (int argc, const char** argv)
|
||||||
a3t.entity ("operator", "^");
|
a3t.entity ("operator", "^");
|
||||||
a3t.entity ("operator", "!");
|
a3t.entity ("operator", "!");
|
||||||
|
|
||||||
|
a3t.findBinary ();
|
||||||
a3t.findCommand ();
|
a3t.findCommand ();
|
||||||
a3t.findUUIDList ();
|
a3t.findUUIDList ();
|
||||||
a3t.findIdSequence ();
|
a3t.findIdSequence ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue