From aa156412b576f925e35b07a010464915c7fda4f8 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 26 Aug 2014 23:28:04 -0400 Subject: [PATCH] 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. --- src/Context.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Context.cpp b/src/Context.cpp index c97c19f2a..88929fde6 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -105,15 +105,9 @@ int Context::initialize (int argc, const char** argv) // Initialize the command line parser. program = (argc ? argv[0] : "task"); - 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:' command line override. - parser.findOverrides (); // rc: rc.: - parser.getOverrides (home_dir, rc_file); // <-- + // Scan command line for 'rc:' only. + Parser::getOverrides (argc, argv, rc_file._data); // TASKRC environment variable overrides the command line. char* override = getenv ("TASKRC"); @@ -125,9 +119,24 @@ int Context::initialize (int argc, const char** argv) // Dump any existing values and load rc file. config.clear (); - config.load (rc_file); + config.load (rc_file); 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:' command line override. + parser.findOverrides (); // rc: rc.: + parser.getOverrides (home_dir, rc_file); // <-- + // 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.