increase cli priority, respect override verbosity.

This commit is contained in:
taiyu
2018-11-15 12:31:35 -08:00
committed by Paul Beckingham
parent d2b1662a39
commit fd441bdd62

View File

@@ -447,20 +447,22 @@ int Context::initialize (int argc, const char** argv)
// //
// [1] Load the correct config file. // [1] Load the correct config file.
// - Default to ~/.taskrc (ctor). // - Default to ~/.taskrc (ctor).
// - Allow command line override rc:<file>
// - Allow $TASKRC override. // - Allow $TASKRC override.
// - Allow command line override rc:<file>
// - Load resultant file. // - Load resultant file.
// - Apply command line overrides to the config. // - Apply command line overrides to the config.
// //
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
CLI2::getOverride (argc, argv, home_dir, rc_file); bool taskrc_overridden = CLI2::getOverride (argc, argv, home_dir, rc_file);
if (! taskrc_overridden)
char* override = getenv ("TASKRC");
if (override)
{ {
rc_file = File (override); char *override = getenv ("TASKRC");
header (format ("TASKRC override: {1}", rc_file._data)); if (override)
{
rc_file = File (override);
taskrc_overridden = true;
}
} }
// Artificial scope for timing purposes. // Artificial scope for timing purposes.
@@ -473,26 +475,33 @@ int Context::initialize (int argc, const char** argv)
CLI2::applyOverrides (argc, argv); CLI2::applyOverrides (argc, argv);
if (taskrc_overridden && verbose ("override"))
header (format ("TASKRC override: {1}", rc_file._data));
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// //
// [2] Locate the data directory. // [2] Locate the data directory.
// - Default to ~/.task (ctor). // - Default to ~/.task (ctor).
// - Allow command line override rc.data.location:<dir>
// - Allow $TASKDATA override. // - Allow $TASKDATA override.
// - Allow command line override rc.data.location:<dir>
// - Inform TDB2 where to find data. // - Inform TDB2 where to find data.
// - Create the rc_file and data_dir, if necessary. // - Create the rc_file and data_dir, if necessary.
// //
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
CLI2::getDataLocation (argc, argv, data_dir); bool taskdata_overridden = CLI2::getDataLocation (argc, argv, data_dir);
if (! taskdata_overridden)
override = getenv ("TASKDATA");
if (override)
{ {
data_dir = Directory (override); char *override = getenv("TASKDATA");
config.set ("data.location", data_dir._data); if (override)
header (format ("TASKDATA override: {1}", data_dir._data)); {
data_dir = Directory (override);
config.set ("data.location", data_dir._data);
taskdata_overridden = true;
}
} }
if (taskdata_overridden && verbose ("override"))
header (format ("TASKDATA override: {1}", data_dir._data));
tdb2.set_location (data_dir); tdb2.set_location (data_dir);
createDefaultConfig (); createDefaultConfig ();