<commit_before>/** @file
    @brief Implementation

    @date 2014

    @author
    <NAME>
    <<EMAIL>>
    <http://sensics.com>

*/

// Copyright 2014 Sensics, Inc.
//
// All rights reserved.
//
// (Final version intended to be licensed under
// the Apache License, Version 2.0)

// Internal Includes
#include <osvr/Server/Server.h>
#include <osvr/Server/RegisterShutdownHandler.h>

// Library/third-party includes
#include <json/value.h>
#include <json/reader.h>

// Standard includes
#include <iostream>
#include <fstream>
#include <exception>

using std::cout;
using std::cerr;
using std::endl;

static osvr::server::ServerPtr server;

/// @brief Shutdown handler function - forcing the server pointer to be global.
void handleShutdown() {
    cout << "Received shutdown signal..." << endl;
    server->signalStop();
}

int main(int argc, char *argv[]) {
    std::string configName = "osvr_server_config.json";
    if (argc > 2) {
        configName = argv[1];
    }
    cout << "Loading config file '" << configName << "'" << endl;
    Json::Value root;
    Json::Reader reader;
    try {
        std::ifstream config(configName);
        bool parsingSuccessful = reader.parse(config, root);
        if (!parsingSuccessful) {
            cerr << "Error in parsing JSON config file" << endl;
            cerr << reader.getFormattedErrorMessages() << endl;
            return 1;
        }
    } catch (std::exception &e) {
        cerr << "Caught exception loading and parsing JSON config file: "
             << e.what() << endl;
        return 1;
    }

    cout << "Creating server..." << endl;
<commit_msg>Print a little usasge help in the server if you don't pass a param.<commit_after>/** @file
    @brief Implementation

    @date 2014

    @author
    <NAME>
    <<EMAIL>>
    <http://sensics.com>

*/

// Copyright 2014 Sensics, Inc.
//
// All rights reserved.
//
// (Final version intended to be licensed under
// the Apache License, Version 2.0)

// Internal Includes
#include <osvr/Server/Server.h>
#include <osvr/Server/RegisterShutdownHandler.h>

// Library/third-party includes
#include <json/value.h>
#include <json/reader.h>

// Standard includes
#include <iostream>
#include <fstream>
#include <exception>

using std::cout;
using std::cerr;
using std::endl;

static osvr::server::ServerPtr server;

/// @brief Shutdown handler function - forcing the server pointer to be global.
void handleShutdown() {
    cout << "Received shutdown signal..." << endl;
    server->signalStop();
}

int main(int argc, char *argv[]) {
    std::string configName = "osvr_server_config.json";
    if (argc > 2) {
        configName = argv[1];
    } else {
        cout << "Using default config file - pass a filename on the command "
                "line to use a different one." << endl;
    }

    cout << "Loading config file '" << configName << "'" << endl;
    Json::Value root;
    Json::Reader reader;
    try {
        std::ifstream config(configName);
        bool parsingSuccessful = reader.parse(config, root);
        if (!parsingSuccessful) {
            cerr << "Error in parsing JSON config file" << endl;
            cerr << reader.getFormattedErrorMessages() << endl;
            return 1;
        }
    } catch (std::exception &e) {
        cerr << "Caught exception loading and parsing JSON config file: "
             << e.what() << endl;
        return 1;
    }

    cout << "Creating server..." << endl;

{'fraction_non_alphanumeric': 0.13848396501457727, 'fraction_numerical': 0.00816326530612245, 'mean_word_length': 2.6852846401718584, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 29, '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': '6571099', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1015, 'n_words': 316}