- Implemented ::getDataLocation.
- Called ::getDataLocation from Context.
This commit is contained in:
Paul Beckingham 2014-11-02 22:10:47 -05:00
parent 7845786398
commit c8dfa8f7fd
3 changed files with 26 additions and 1 deletions

View file

@ -379,6 +379,29 @@ void CLI::getOverride (std::string& home, File& rc)
}
}
////////////////////////////////////////////////////////////////////////////////
// Look for CONFIG data.location and initialize a Path object.
void CLI::getDataLocation (Path& data)
{
std::string location = context.config.get ("data.location");
if (location != "")
data = location;
std::vector <A>::const_iterator a;
for (a = _args.begin (); a != _args.end (); ++a)
{
if (a->hasTag ("CONFIG") &&
a->attribute ("name") == "data.location")
{
data = Directory (a->attribute ("value"));
context.header (format (STRING_PARSER_ALTERNATE_DATA, (std::string) data));
}
// Keep looping, because if there are multiple overrides, the last one
// should dominate.
}
}
////////////////////////////////////////////////////////////////////////////////
// Extract all the FILTER-tagged items.
const std::string CLI::getFilter ()

View file

@ -29,6 +29,7 @@
#include <string>
#include <vector>
#include <map>
#include <Path.h>
#include <File.h>
// Represents a single argument.
@ -71,6 +72,7 @@ public:
void add (const std::string&);
void analyze (bool parse = true);
void getOverride (std::string&, File&);
void getDataLocation (Path&);
const std::string getFilter ();
const std::vector <std::string> getWords ();
const std::vector <std::string> getModifications ();

View file

@ -166,7 +166,7 @@ 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.
parser.getDataLocation (data_dir); // <-- rc.data.location=<location>
cli.getDataLocation (data_dir); // <-- rc.data.location=<location>
override = getenv ("TASKDATA");
if (override)