From 6f948826a74be6d9e69fd756bf832a90b02e715a Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 20 Apr 2014 09:26:01 -0400 Subject: [PATCH] A3t - Combined ::findFileOverride and ::findConfigOverride into ::findOverride. - Made ::findBinary public, and corrected comment. --- src/A3t.cpp | 30 +++++------------------------- src/A3t.h | 5 ++--- src/Context.cpp | 9 ++++----- src/args.cpp | 4 ++-- 4 files changed, 13 insertions(+), 35 deletions(-) diff --git a/src/A3t.cpp b/src/A3t.cpp index abbd91407..405e8e11e 100644 --- a/src/A3t.cpp +++ b/src/A3t.cpp @@ -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:' command line override. -void A3t::findFileOverride () +// rc: +// rc.[:=] +void A3t::findOverrides () { std::vector ::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.[:=] -void A3t::findConfigOverride () -{ - std::vector ::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) diff --git a/src/A3t.h b/src/A3t.h index ea32b51e9..d542e4441 100644 --- a/src/A3t.h +++ b/src/A3t.h @@ -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 (); diff --git a/src/Context.cpp b/src/Context.cpp index 8ce58078d..128f9c6f4 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -114,8 +114,7 @@ int Context::initialize (int argc, const char** argv) // Process 'rc:' command line override, and remove the argument from the // Context::a3. a3.categorize (); - - a3t.findFileOverride (); // rc: + a3t.findOverrides (); // rc: rc.: a3t.get_overrides (home_dir, rc_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.[:=] a3t.get_data_location (data_dir); // <-- rc.data.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 (); // a3t.findCommand (); // a3t.findUUIDList (); // Before findIdSequence a3t.findIdSequence (); // @@ -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")) diff --git a/src/args.cpp b/src/args.cpp index 13e7f190c..99dcf28c6 100644 --- a/src/args.cpp +++ b/src/args.cpp @@ -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 ();