mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
init: Propagated database to CmdConfig
This commit is contained in:
parent
4d90aa7b2d
commit
510de67fd3
3 changed files with 8 additions and 7 deletions
|
@ -39,7 +39,7 @@
|
||||||
// Note that because this function does not recurse with includes, it therefore
|
// Note that because this function does not recurse with includes, it therefore
|
||||||
// only sees the top-level settings. This has the desirable effect of adding as
|
// only sees the top-level settings. This has the desirable effect of adding as
|
||||||
// an override any setting which resides in an imported file.
|
// an override any setting which resides in an imported file.
|
||||||
static bool setConfigVariable (const Rules& rules, std::string name, std::string value, bool confirmation /* = false */)
|
static bool setConfigVariable (Database& database, const Rules& rules, std::string name, std::string value, bool confirmation /* = false */)
|
||||||
{
|
{
|
||||||
// Read config file as lines of text.
|
// Read config file as lines of text.
|
||||||
std::vector <std::string> lines;
|
std::vector <std::string> lines;
|
||||||
|
@ -140,7 +140,7 @@ static bool setConfigVariable (const Rules& rules, std::string name, std::string
|
||||||
// 0 - found and removed
|
// 0 - found and removed
|
||||||
// 1 - found and not removed
|
// 1 - found and not removed
|
||||||
// 2 - not found
|
// 2 - not found
|
||||||
static int unsetConfigVariable (const Rules& rules, std::string name, bool confirmation /* = false */)
|
static int unsetConfigVariable (Database& database, const Rules& rules, std::string name, bool confirmation /* = false */)
|
||||||
{
|
{
|
||||||
// Setting not found.
|
// Setting not found.
|
||||||
if (! rules.has (name))
|
if (! rules.has (name))
|
||||||
|
@ -218,7 +218,8 @@ static int unsetConfigVariable (const Rules& rules, std::string name, bool confi
|
||||||
// timew config Show all config
|
// timew config Show all config
|
||||||
int CmdConfig (
|
int CmdConfig (
|
||||||
const CLI& cli,
|
const CLI& cli,
|
||||||
Rules& rules)
|
Rules& rules,
|
||||||
|
Database& database)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
@ -255,7 +256,7 @@ int CmdConfig (
|
||||||
// task config name ""
|
// task config name ""
|
||||||
if (words.size () > 1)
|
if (words.size () > 1)
|
||||||
{
|
{
|
||||||
change = setConfigVariable (rules, name, value, confirmation);
|
change = setConfigVariable (database, rules, name, value, confirmation);
|
||||||
if (! change)
|
if (! change)
|
||||||
rc = 1;
|
rc = 1;
|
||||||
}
|
}
|
||||||
|
@ -264,7 +265,7 @@ int CmdConfig (
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
rc = unsetConfigVariable (rules, name, confirmation);
|
rc = unsetConfigVariable (database, rules, name, confirmation);
|
||||||
if (rc == 0)
|
if (rc == 0)
|
||||||
{
|
{
|
||||||
change = true;
|
change = true;
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
int CmdCancel ( Rules&, Database& );
|
int CmdCancel ( Rules&, Database& );
|
||||||
int CmdClear (const CLI&, Rules&, Database& );
|
int CmdClear (const CLI&, Rules&, Database& );
|
||||||
int CmdConfig (const CLI&, Rules& );
|
int CmdConfig (const CLI&, Rules&, Database& );
|
||||||
int CmdContinue ( Rules&, Database& );
|
int CmdContinue ( Rules&, Database& );
|
||||||
int CmdDefault ( Rules&, Database& );
|
int CmdDefault ( Rules&, Database& );
|
||||||
int CmdDiagnostics ( Rules&, Database&, const Extensions&);
|
int CmdDiagnostics ( Rules&, Database&, const Extensions&);
|
||||||
|
|
|
@ -228,7 +228,7 @@ int dispatchCommand (
|
||||||
// command to fn mapping.
|
// command to fn mapping.
|
||||||
if (command == "cancel") status = CmdCancel ( rules, database );
|
if (command == "cancel") status = CmdCancel ( rules, database );
|
||||||
else if (command == "clear") status = CmdClear (cli, rules, database );
|
else if (command == "clear") status = CmdClear (cli, rules, database );
|
||||||
else if (command == "config") status = CmdConfig (cli, rules );
|
else if (command == "config") status = CmdConfig (cli, rules, database );
|
||||||
else if (command == "continue") status = CmdContinue ( rules, database );
|
else if (command == "continue") status = CmdContinue ( rules, database );
|
||||||
else if (command == "day") status = CmdReportDay (cli, rules, database );
|
else if (command == "day") status = CmdReportDay (cli, rules, database );
|
||||||
else if (command == "diagnostics") status = CmdDiagnostics ( rules, database, extensions);
|
else if (command == "diagnostics") status = CmdDiagnostics ( rules, database, extensions);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue