From d49222e8c7a56a955e634bf8be11e48d366cd4a4 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 2 Nov 2014 21:14:08 -0500 Subject: [PATCH] CLI - Implemented ::getOverride, and updated Context to use it. --- src/CLI.cpp | 11 +++++++++++ src/CLI.h | 1 + src/Context.cpp | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/CLI.cpp b/src/CLI.cpp index 249d3f16a..386208dd4 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -354,6 +354,17 @@ void CLI::analyze (bool parse /* = true */) context.debug ("CLI::analyze end"); } +//////////////////////////////////////////////////////////////////////////////// +const std::string CLI::getOverride () +{ + std::vector ::const_iterator a; + for (a = _args.begin (); a != _args.end (); ++a) + if (a->hasTag ("RC")) + return a->attribute ("file"); + + return ""; +} + //////////////////////////////////////////////////////////////////////////////// // Extract all the FILTER-tagged items. const std::string CLI::getFilter () diff --git a/src/CLI.h b/src/CLI.h index 618857b90..d9469ffcc 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -69,6 +69,7 @@ public: void initialize (int, const char**); void add (const std::string&); void analyze (bool parse = true); + const std::string getOverride (); const std::string getFilter (); const std::vector getWords (); const std::vector getModifications (); diff --git a/src/Context.cpp b/src/Context.cpp index dfaacdad0..32b7dff1a 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -138,8 +138,8 @@ int Context::initialize (int argc, const char** argv) program = (argc ? argv[0] : "task"); // Scan command line for 'rc:' only. - Parser::getOverrides (argc, argv, rc_file._data); cli.initialize (argc, argv); // task arg0 arg1 ... + rc_file._data = cli.getOverride (); // TASKRC environment variable overrides the command line. char* override = getenv ("TASKRC");