mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Timew: Added rules object to assorted calls
This commit is contained in:
parent
7ac5da025f
commit
7434ad59c2
3 changed files with 13 additions and 10 deletions
19
src/init.cpp
19
src/init.cpp
|
@ -65,13 +65,13 @@ void initializeData (
|
||||||
char* override = getenv ("TIMEWARRIORDB");
|
char* override = getenv ("TIMEWARRIORDB");
|
||||||
if (override)
|
if (override)
|
||||||
{
|
{
|
||||||
std::cout << "# TIMEWARRIORDB " << override << "\n";
|
log.write ("info", std::string ("TIMEWARRIORDB ") + override);
|
||||||
dbLocation = Directory (override);
|
dbLocation = Directory (override);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dbLocation = Directory ("~/.timewarrior");
|
dbLocation = Directory ("~/.timewarrior");
|
||||||
std::cout << "# Using default DB location " << dbLocation._data << "\n";
|
log.write ("info", std::string ("Using default DB location ") + dbLocation._data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If dbLocation does not exist, ask whether it should be created.
|
// If dbLocation does not exist, ask whether it should be created.
|
||||||
|
@ -80,7 +80,7 @@ void initializeData (
|
||||||
confirm ("Create new database in " + dbLocation._data + "?"))
|
confirm ("Create new database in " + dbLocation._data + "?"))
|
||||||
{
|
{
|
||||||
dbLocation.create (0700);
|
dbLocation.create (0700);
|
||||||
std::cout << "# Created missing database in " << dbLocation._data << "\n";
|
log.write ("info", std::string ("Created missing database in ") + dbLocation._data);
|
||||||
shinyNewDatabase = true;
|
shinyNewDatabase = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void initializeData (
|
||||||
// located the config file, the 'db' location is already known. This is just
|
// located the config file, the 'db' location is already known. This is just
|
||||||
// for subsequent internal use.
|
// for subsequent internal use.
|
||||||
configuration.set ("db", dbLocation._data);
|
configuration.set ("db", dbLocation._data);
|
||||||
std::cout << "# rc.db=" << configuration.get ("db") << "\n";
|
log.write ("info", std::string (" rc.db=") + configuration.get ("db"));
|
||||||
|
|
||||||
// Perhaps some subsequent code would like to know this is a new db and
|
// Perhaps some subsequent code would like to know this is a new db and
|
||||||
// possibly a first run.
|
// possibly a first run.
|
||||||
|
@ -127,11 +127,11 @@ void initializeData (
|
||||||
// TODO Give the log file a temp fake name. To be removed.
|
// TODO Give the log file a temp fake name. To be removed.
|
||||||
log.file (dbLocation._data + "/timewarrior.log");
|
log.file (dbLocation._data + "/timewarrior.log");
|
||||||
|
|
||||||
std::cout << "# Configuration\n";
|
log.write ("info", "Configuration");
|
||||||
for (const auto& name : configuration.all ())
|
for (const auto& name : configuration.all ())
|
||||||
std::cout << "# " << name << "=" << configuration[name] << "\n";
|
log.write ("info", std::string (" ") + name + "=" + configuration[name]);
|
||||||
|
|
||||||
std::cout << database.dump ();
|
log.write ("info", database.dump ());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -154,12 +154,15 @@ void initializeRules (
|
||||||
ruleParser.initialize (ruleGrammar);
|
ruleParser.initialize (ruleGrammar);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::cout << "# " << rules.dump ();
|
rules.load (configuration.get ("db") + "/timewarrior.cfg");
|
||||||
|
|
||||||
|
log.write ("info", rules.dump ());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void initializeExtensions (
|
void initializeExtensions (
|
||||||
Configuration& configuration,
|
Configuration& configuration,
|
||||||
|
Rules& rules,
|
||||||
Extensions& extensions,
|
Extensions& extensions,
|
||||||
Log& log)
|
Log& log)
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,7 +90,7 @@ int main (int argc, const char** argv)
|
||||||
|
|
||||||
// Load extension script info.
|
// Load extension script info.
|
||||||
Extensions extensions;
|
Extensions extensions;
|
||||||
initializeExtensions (configuration, extensions, log);
|
initializeExtensions (configuration, rules, extensions, log);
|
||||||
|
|
||||||
// Dispatch to commands.
|
// Dispatch to commands.
|
||||||
status = dispatchCommand (args, configuration, database, rules, extensions, log);
|
status = dispatchCommand (args, configuration, database, rules, extensions, log);
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
bool lightweightVersionCheck (const std::vector <std::string>&);
|
bool lightweightVersionCheck (const std::vector <std::string>&);
|
||||||
void initializeData (Configuration&, Database&, Log&);
|
void initializeData (Configuration&, Database&, Log&);
|
||||||
void initializeRules (Configuration&, Rules&, Log&);
|
void initializeRules (Configuration&, Rules&, Log&);
|
||||||
void initializeExtensions (Configuration&, Extensions&, Log&);
|
void initializeExtensions (Configuration&, Rules&, Extensions&, Log&);
|
||||||
int dispatchCommand (const std::vector <std::string>&, Configuration&, Database&, Rules&, Extensions&, Log&);
|
int dispatchCommand (const std::vector <std::string>&, Configuration&, Database&, Rules&, Extensions&, Log&);
|
||||||
|
|
||||||
// utiŀ.cpp
|
// utiŀ.cpp
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue