Rules: Replacing Configuration

This commit is contained in:
Paul Beckingham 2016-03-17 22:23:07 -04:00
parent 16cd5a6501
commit f3aa253b07
3 changed files with 9 additions and 10 deletions

View file

@ -55,6 +55,7 @@ bool lightweightVersionCheck (const std::vector <std::string>& args)
////////////////////////////////////////////////////////////////////////////////
void initializeData (
Database& database,
Rules& rules,
Log& log)
{
// The $TIMEWARRIORDB environment variable overrides the default value of
@ -88,7 +89,7 @@ void initializeData (
if (! extensions.exists ())
extensions.create (0700);
// Create extensions subdirectory if necessary.
// Create data subdirectory if necessary.
Directory data (dbLocation);
data += "data";
if (! data.exists ())
@ -107,22 +108,19 @@ void initializeData (
File configFile (dbLocation);
configFile += "timewarrior.cfg";
configFile.create (0600);
/*
configuration.load (configFile._data);
*/
// This value is not written out to disk, as there would be no point. Having
// located the config file, the 'db' location is already known. This is just
// for subsequent internal use.
/*
configuration.set ("db", dbLocation._data);
log.write ("info", std::string (" rc.db=") + configuration.get ("db"));
rules.set ("db", dbLocation._data);
log.write ("info", std::string (" rc.db=") + rules.get ("db"));
*/
// Perhaps some subsequent code would like to know this is a new db and
// possibly a first run.
/*
configuration.set ("shiny", (shinyNewDatabase ? 1 : 0));
rules.set ("shiny", (shinyNewDatabase ? 1 : 0));
*/
// Initialize the database (no data read), but files are enumerated.

View file

@ -30,6 +30,7 @@
#include <Extensions.h>
#include <Log.h>
//#include <Grammar.h>
#include <FS.h>
#include <shared.h>
#include <commands.h>
#include <timew.h>
@ -61,7 +62,8 @@ int main (int argc, const char** argv)
{
// Prepare the database, but do not read data.
Database database;
initializeData (database, log);
Rules rules;
initializeData (database, rules, log);
// TODO Arrange the following to minimize memory use.
// TODO Load CLI grammar.
@ -81,7 +83,6 @@ int main (int argc, const char** argv)
*/
// Load the rules.
Rules rules;
initializeRules (rules, log);
// Load extension script info.

View file

@ -34,7 +34,7 @@
// init.cpp
bool lightweightVersionCheck (const std::vector <std::string>&);
void initializeData (Database&, Log&);
void initializeData (Database&, Rules&, Log&);
void initializeRules (Rules&, Log&);
void initializeExtensions (Rules&, Extensions&, Log&);
int dispatchCommand (const std::vector <std::string>&, Database&, Rules&, Extensions&, Log&);