<commit_before>////////////////////////////////////////////////////////////
//
// DAGON - An Adventure Game Engine
// Copyright (c) 2011-2014 Senscape s.r.l.
// All rights reserved.
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL was
// not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/.
//
////////////////////////////////////////////////////////////

#include "Control.h"

int main(int argc, char *argv[]) {
  dagon::Control& control = dagon::Control::instance();
  
  control.init(argc, argv);
  control.run();
  
  return 0;
}<commit_msg>added simple command line options (--help and --version)<commit_after>////////////////////////////////////////////////////////////
//
// DAGON - An Adventure Game Engine
// Copyright (c) 2011-2014 Senscape s.r.l.
// All rights reserved.
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL was
// not distributed with this file, You can obtain one at
// http://mozilla.org/MPL/2.0/.
//
////////////////////////////////////////////////////////////

#include "Control.h"
#include "Version.h"

bool shouldStartApp(int argc, char *argv[]);

int main(int argc, char *argv[]) {
  if (!shouldStartApp(argc, argv)) {
    return 0;
  }

  dagon::Control& control = dagon::Control::instance();
  
  control.init(argc, argv);
  control.run();
  
  return 0;
}

void displayHelp(char* progName)
{
    printf("\n"
           "DAGON - An Adventure Game Engine\n\n"
           "To start a game, run Dagon in a directory containing a config.lua file.\n\n"
           "Usage:\n"
           "  %s\n"
           "  %s [-h|--help]\n"
           "  %s [-v|--version]\n",
           progName,
           progName,
           progName);
}

void displayVersion()
{
    printf(DAGON_VERSION_STRING "\n");
}

inline
bool shouldStartApp(int argc, char* argv[])
{
#define MATCHES_OPT(str, short, long) \
    strcmp(str, short)==0 || strcmp(str, long)==0
    
    if (argc > 1) {
        const char* const firstArg = argv[1];
        if (MATCHES_OPT(firstArg, "-h", "--help")) {
          displayHelp(argv[0]);
          return false;
        }
        
        if (MATCHES_OPT(firstArg, "-v", "--version")) {
          displayVersion();
          return false;
        }
        
    }
    return true;
    
#undef MATCHES_OPT
}
{'fraction_non_alphanumeric': 0.2344139650872818, 'fraction_numerical': 0.013300083125519535, 'mean_word_length': 1.6714761376248612, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '50974', 'n_tokens_mistral': 764, 'n_tokens_neox': 725, 'n_words': 220}