Context
- Reorganized ::inintialize sequence regarding Parser::initialize and the need for the rc file to be loaded (and/or overridden) before full parsing could proceed.
This commit is contained in:
@@ -105,15 +105,9 @@ int Context::initialize (int argc, const char** argv)
|
|||||||
|
|
||||||
// Initialize the command line parser.
|
// Initialize the command line parser.
|
||||||
program = (argc ? argv[0] : "task");
|
program = (argc ? argv[0] : "task");
|
||||||
parser.initialize (argc, argv); // task arg0 arg1 ...
|
|
||||||
|
|
||||||
// echo one two -- three | task zero --> task zero one two
|
// Scan command line for 'rc:<file>' only.
|
||||||
// 'three' is left in the input buffer.
|
Parser::getOverrides (argc, argv, rc_file._data);
|
||||||
parser.appendStdin (); // echo stdin0 | task ...
|
|
||||||
|
|
||||||
// Process 'rc:<file>' command line override.
|
|
||||||
parser.findOverrides (); // rc:<file> rc.<name>:<value>
|
|
||||||
parser.getOverrides (home_dir, rc_file); // <-- <file>
|
|
||||||
|
|
||||||
// TASKRC environment variable overrides the command line.
|
// TASKRC environment variable overrides the command line.
|
||||||
char* override = getenv ("TASKRC");
|
char* override = getenv ("TASKRC");
|
||||||
@@ -125,9 +119,24 @@ int Context::initialize (int argc, const char** argv)
|
|||||||
|
|
||||||
// Dump any existing values and load rc file.
|
// Dump any existing values and load rc file.
|
||||||
config.clear ();
|
config.clear ();
|
||||||
config.load (rc_file);
|
config.load (rc_file);
|
||||||
loadAliases ();
|
loadAliases ();
|
||||||
|
|
||||||
|
// These are needed in Parser::initialize.
|
||||||
|
Lexer::dateFormat = config.get ("dateformat");
|
||||||
|
Variant::dateFormat = config.get ("dateformat");
|
||||||
|
Variant::searchCaseSensitive = config.getBoolean ("search.case.sensitive");
|
||||||
|
|
||||||
|
parser.initialize (argc, argv); // task arg0 arg1 ...
|
||||||
|
|
||||||
|
// echo one two -- three | task zero --> task zero one two
|
||||||
|
// 'three' is left in the input buffer.
|
||||||
|
parser.appendStdin (); // echo stdin0 | task ...
|
||||||
|
|
||||||
|
// Process 'rc:<file>' command line override.
|
||||||
|
parser.findOverrides (); // rc:<file> rc.<name>:<value>
|
||||||
|
parser.getOverrides (home_dir, rc_file); // <-- <file>
|
||||||
|
|
||||||
// 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.
|
||||||
|
|||||||
Reference in New Issue
Block a user