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 ( void initializeData (
Database& database, Database& database,
Rules& rules,
Log& log) Log& log)
{ {
// The $TIMEWARRIORDB environment variable overrides the default value of // The $TIMEWARRIORDB environment variable overrides the default value of
@ -88,7 +89,7 @@ void initializeData (
if (! extensions.exists ()) if (! extensions.exists ())
extensions.create (0700); extensions.create (0700);
// Create extensions subdirectory if necessary. // Create data subdirectory if necessary.
Directory data (dbLocation); Directory data (dbLocation);
data += "data"; data += "data";
if (! data.exists ()) if (! data.exists ())
@ -107,22 +108,19 @@ void initializeData (
File configFile (dbLocation); File configFile (dbLocation);
configFile += "timewarrior.cfg"; configFile += "timewarrior.cfg";
configFile.create (0600); configFile.create (0600);
/*
configuration.load (configFile._data);
*/
// This value is not written out to disk, as there would be no point. Having // 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 // 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); rules.set ("db", dbLocation._data);
log.write ("info", std::string (" rc.db=") + configuration.get ("db")); log.write ("info", std::string (" rc.db=") + rules.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.
/* /*
configuration.set ("shiny", (shinyNewDatabase ? 1 : 0)); rules.set ("shiny", (shinyNewDatabase ? 1 : 0));
*/ */
// Initialize the database (no data read), but files are enumerated. // Initialize the database (no data read), but files are enumerated.

View file

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

View file

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