mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 17:07:19 +02:00
Bug Fix - rc:alternate
- Fixed handling of rc: alternate rc file. - Reorganized Config.cpp regarding defaults. More work needed.
This commit is contained in:
parent
4470c3b88c
commit
00c5e61d49
6 changed files with 147 additions and 116 deletions
|
@ -272,6 +272,8 @@ void Context::shadow ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Context::loadCorrectConfigFile ()
|
||||
{
|
||||
bool needNewConfig = true;
|
||||
|
||||
foreach (arg, args)
|
||||
{
|
||||
if (arg->substr (0, 3) == "rc:")
|
||||
|
@ -281,21 +283,26 @@ void Context::loadCorrectConfigFile ()
|
|||
throw std::string ("Could not read configuration file '") + file + "'";
|
||||
|
||||
message (std::string ("Using alternate .taskrc file ") + file); // TODO i18n
|
||||
config.load (file);
|
||||
config.clear (); // Dump current values.
|
||||
config.setDefaults (); // Add in the custom reports.
|
||||
config.load (file); // Load new file.
|
||||
needNewConfig = false;
|
||||
|
||||
// No need to handle it again.
|
||||
args.erase (arg);
|
||||
}
|
||||
}
|
||||
|
||||
struct passwd* pw = getpwuid (getuid ());
|
||||
if (!pw)
|
||||
throw std::string (
|
||||
stringtable.get (SHELL_READ_PASSWD,
|
||||
"Could not read home directory from the passwd file."));
|
||||
if (needNewConfig)
|
||||
{
|
||||
struct passwd* pw = getpwuid (getuid ());
|
||||
if (!pw)
|
||||
throw std::string (
|
||||
stringtable.get (SHELL_READ_PASSWD,
|
||||
"Could not read home directory from the passwd file."));
|
||||
|
||||
std::string file = pw->pw_dir;
|
||||
config.createDefault (file);
|
||||
config.createDefault (pw->pw_dir);
|
||||
}
|
||||
|
||||
// Apply overrides of type: "rc.name:value"
|
||||
foreach (arg, args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue