mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-30 11:27:19 +02:00
Context
- Added CLI rc: and rc. override extraction.
This commit is contained in:
parent
226c143922
commit
f4183fd6b1
1 changed files with 21 additions and 1 deletions
|
@ -108,6 +108,11 @@ int Context::initialize (int argc, const char** argv)
|
||||||
|
|
||||||
// Scan command line for 'rc:<file>' only.
|
// Scan command line for 'rc:<file>' only.
|
||||||
Parser::getOverrides (argc, argv, rc_file._data);
|
Parser::getOverrides (argc, argv, rc_file._data);
|
||||||
|
cli.initialize (argc, argv); // task arg0 arg1 ...
|
||||||
|
/*
|
||||||
|
std::cout << "# cli._rc=" << cli._rc << "\n";
|
||||||
|
rc_file = cli._rc;
|
||||||
|
*/
|
||||||
|
|
||||||
// TASKRC environment variable overrides the command line.
|
// TASKRC environment variable overrides the command line.
|
||||||
char* override = getenv ("TASKRC");
|
char* override = getenv ("TASKRC");
|
||||||
|
@ -129,16 +134,31 @@ int Context::initialize (int argc, const char** argv)
|
||||||
Variant::searchUsingRegex = config.getBoolean ("regex");
|
Variant::searchUsingRegex = config.getBoolean ("regex");
|
||||||
|
|
||||||
parser.initialize (argc, argv); // task arg0 arg1 ...
|
parser.initialize (argc, argv); // task arg0 arg1 ...
|
||||||
cli.initialize (argc, argv); // task arg0 arg1 ...
|
|
||||||
|
|
||||||
// Process 'rc:<file>' command line override.
|
// Process 'rc:<file>' command line override.
|
||||||
parser.findOverrides (); // rc:<file> rc.<name>:<value>
|
parser.findOverrides (); // rc:<file> rc.<name>:<value>
|
||||||
parser.getOverrides (home_dir, rc_file); // <-- <file>
|
parser.getOverrides (home_dir, rc_file); // <-- <file>
|
||||||
|
/*
|
||||||
|
home_dir = rc_file;
|
||||||
|
std::string::size_type last_slash = rc._data.rfind ("/");
|
||||||
|
if (last_slash != std::string::npos)
|
||||||
|
home_dir = rc_file.parent ();
|
||||||
|
else
|
||||||
|
home_dir = ".";
|
||||||
|
std::cout << "# home_dir=" << home_dir << "\n";
|
||||||
|
*/
|
||||||
|
|
||||||
// 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.
|
||||||
parser.getDataLocation (data_dir); // <-- rc.data.location=<location>
|
parser.getDataLocation (data_dir); // <-- rc.data.location=<location>
|
||||||
|
/*
|
||||||
|
if (cli._overrides.find ("data.location") != cli._overrides.end ())
|
||||||
|
data_dir = cli._overrides["data.location"];
|
||||||
|
else
|
||||||
|
data_dir = config.get ("data.location");
|
||||||
|
std::cout << "# data_dir=" << data_dir << "\n";
|
||||||
|
*/
|
||||||
|
|
||||||
override = getenv ("TASKDATA");
|
override = getenv ("TASKDATA");
|
||||||
if (override)
|
if (override)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue