mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
init: Combined initializeData and initializeRules
This commit is contained in:
parent
0403c21002
commit
78ff8b2919
3 changed files with 18 additions and 51 deletions
50
src/init.cpp
50
src/init.cpp
|
@ -53,7 +53,7 @@ bool lightweightVersionCheck (const std::vector <std::string>& args)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void initializeData (
|
||||
void initializeDataAndRules (
|
||||
Database& database,
|
||||
Rules& rules,
|
||||
Log& log)
|
||||
|
@ -104,10 +104,24 @@ void initializeData (
|
|||
throw format ("Database is not readable at '{1}'", dbLocation._data);
|
||||
}
|
||||
|
||||
// TODO Load rule grammar.
|
||||
/*
|
||||
File ruleFile ("./rule.grammar");
|
||||
Grammar ruleGrammar;
|
||||
ruleGrammar.debug (debug);
|
||||
ruleGrammar.loadFromFile (ruleFile);
|
||||
|
||||
// Instantiate the parser.
|
||||
LR0 ruleParser;
|
||||
ruleParser.debug (debug);
|
||||
ruleParser.initialize (ruleGrammar);
|
||||
*/
|
||||
|
||||
// Load the configuration data.
|
||||
File configFile (dbLocation);
|
||||
configFile += "timewarrior.cfg";
|
||||
configFile.create (0600);
|
||||
rules.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
|
||||
|
@ -121,42 +135,10 @@ void initializeData (
|
|||
|
||||
// Initialize the database (no data read), but files are enumerated.
|
||||
database.initialize (data._data);
|
||||
log.write ("info", database.dump ());
|
||||
|
||||
// TODO Give the log file a temp fake name. To be removed.
|
||||
log.file (dbLocation._data + "/timewarrior.log");
|
||||
|
||||
/*
|
||||
log.write ("info", "Configuration");
|
||||
for (const auto& name : configuration.all ())
|
||||
log.write ("info", std::string (" ") + name + "=" + configuration[name]);
|
||||
*/
|
||||
|
||||
log.write ("info", database.dump ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void initializeRules (
|
||||
Rules& rules,
|
||||
Log& log)
|
||||
{
|
||||
// TODO Load rule grammar.
|
||||
/*
|
||||
File ruleFile ("./rule.grammar");
|
||||
Grammar ruleGrammar;
|
||||
ruleGrammar.debug (debug);
|
||||
ruleGrammar.loadFromFile (ruleFile);
|
||||
*/
|
||||
// Instantiate the parser.
|
||||
/*
|
||||
LR0 ruleParser;
|
||||
ruleParser.debug (debug);
|
||||
ruleParser.initialize (ruleGrammar);
|
||||
*/
|
||||
|
||||
/*
|
||||
rules.load (configuration.get ("db") + "/timewarrior.cfg");
|
||||
*/
|
||||
|
||||
log.write ("info", rules.dump ());
|
||||
}
|
||||
|
||||
|
|
|
@ -63,27 +63,13 @@ int main (int argc, const char** argv)
|
|||
// Prepare the database, but do not read data.
|
||||
Database database;
|
||||
Rules rules;
|
||||
initializeData (database, rules, log);
|
||||
initializeDataAndRules (database, rules, log);
|
||||
|
||||
// TODO Arrange the following to minimize memory use.
|
||||
// TODO Load CLI grammar.
|
||||
// TODO Load from string, else file on config override.
|
||||
// TODO Migrate from loading a grammar from file, to a default string.
|
||||
/*
|
||||
File cliFile ("./cli.grammar");
|
||||
Grammar cliGrammar;
|
||||
cliGrammar.debug (debug);
|
||||
cliGrammar.loadFromFile (cliFile);
|
||||
|
||||
// Instantiate the parser.
|
||||
LR0 cliParser;
|
||||
cliParser.debug (debug);
|
||||
cliParser.initialize (cliGrammar);
|
||||
// TODO Parse CLI.
|
||||
*/
|
||||
|
||||
// Load the rules.
|
||||
initializeRules (rules, log);
|
||||
|
||||
// Load extension script info.
|
||||
Extensions extensions;
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
|
||||
// init.cpp
|
||||
bool lightweightVersionCheck (const std::vector <std::string>&);
|
||||
void initializeData (Database&, Rules&, Log&);
|
||||
void initializeRules (Rules&, Log&);
|
||||
void initializeDataAndRules (Database&, Rules&, Log&);
|
||||
void initializeExtensions (Rules&, Extensions&, Log&);
|
||||
int dispatchCommand (const std::vector <std::string>&, Database&, Rules&, Extensions&, Log&);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue