init: lightweightVersionCheck no longer requires any arg processing

This commit is contained in:
Paul Beckingham 2016-04-02 13:04:39 -04:00
parent 85c18376e3
commit 370c024409
3 changed files with 8 additions and 8 deletions

View file

@ -41,9 +41,9 @@
#include <iostream>
////////////////////////////////////////////////////////////////////////////////
bool lightweightVersionCheck (const std::vector <std::string>& args)
bool lightweightVersionCheck (int argc, const char** argv)
{
if (args.size () == 2 && args[1] == "--version")
if (argc == 2 && std::string (argv[1]) == "--version")
{
std::cout << VERSION << "\n";
return true;

View file

@ -38,6 +38,11 @@
////////////////////////////////////////////////////////////////////////////////
int main (int argc, const char** argv)
{
// Lightweight version checking that doesn't require initialization or I/O.
int status = 0;
if (lightweightVersionCheck (argc, argv))
return status;
// The log is needed early, in order to capture as much as possible, but will
// only be given a file name once the rules are loaded. The log therefore
// buffers the messages until it has a file name to write to.
@ -49,11 +54,6 @@ int main (int argc, const char** argv)
for (int i = 0; i < argc; i++)
args.push_back (argv[i]);
// Lightweight version checking that doesn't require initialization or I/O.
int status = 0;
if (lightweightVersionCheck (args))
return status;
try
{
// Prepare the database, but do not read data.

View file

@ -35,7 +35,7 @@
#include <Color.h>
// init.cpp
bool lightweightVersionCheck (const std::vector <std::string>&);
bool lightweightVersionCheck (int, const char**);
void initializeDataAndRules (Database&, Rules&, Log&);
void initializeExtensions (Rules&, Extensions&, Log&);
int dispatchCommand (const std::vector <std::string>&, Database&, Rules&, Extensions&, Log&);