<commit_before>/**
 *    Copyright 2017 <NAME>
 * 
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 * 
 *        http://www.apache.org/licenses/LICENSE-2.0
 * 
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
#include "receiverd_main.h"

static void show_help(char **argv) {
	gru_cli_program_usage("mpt-receiverd", argv[0]);

	gru_cli_option_help("help", "h", "show this help");
	gru_cli_option_help("maestro-url", "m", "maestro URL to connect to");
	gru_cli_option_help("log-level", "l",
		"runs in the given verbose (info, stat, debug, etc) level mode");
	gru_cli_option_help("log-dir", "L", 
		"a directory to save the logs (mandatory for --daemon)");
}


int main(int argc, char **argv) {
	int c;
	int option_index = 0;

	options_t *options = options_new();
	set_options_object(options);

	gru_status_t status = gru_status_new();

	if (!options) {
		return EXIT_FAILURE;
	}

	if (argc < 2) {
		show_help(argv);

		return EXIT_FAILURE;
	}

	gru_logger_set(gru_logger_default_printer);

	while (1) {

		static struct option long_options[] = {
			{"log-level", true, 0, 'l'},
			{"log-dir", true, 0, 'L'},
			{"maestro-url", true, 0, 'm'},
			{"help", false, 0, 'h'},
			{0, 0, 0, 0}};

		c = getopt_long(argc, argv, "L:l:m:h", long_options, &option_index);
		if (c == -1) {
			break;
		}

		switch (c) {
			case 'l':
				options->log_level = gru_logger_get_level(optarg);
				gru_logger_set_mininum(options->log_level);
				break;
			case 'L':
				strncpy(options->logdir, optarg, sizeof(options->logdir) - 1);
				break;
			case 'm':
				options->maestro_uri = gru_uri_parse(optarg, &status);
				if (gru_status_error(&status)) {
					fprintf(stderr, "%s", status.message);
					goto err_exit;
				}
				break;
			case 'h':
				show_help(argv);
				return EXIT_SUCCESS;
			default:
				printf("Invalid or missing option\n");
				show_help(argv);
				return EXIT_SUCCESS;
		}
	}

	init_controller(true, options->logdir, "mpt-receiver-daemon");
	receiverd_worker_start(options);

success_exit:
	options_destroy(&options);
	return EXIT_SUCCESS;

err_exit:
	options_destroy(&options);
	return EXIT_FAILURE;
}<commit_msg>FIX: removed unused label<commit_after>/**
 *    Copyright 2017 <NAME>
 * 
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 * 
 *        http://www.apache.org/licenses/LICENSE-2.0
 * 
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
#include "receiverd_main.h"

static void show_help(char **argv) {
	gru_cli_program_usage("mpt-receiverd", argv[0]);

	gru_cli_option_help("help", "h", "show this help");
	gru_cli_option_help("maestro-url", "m", "maestro URL to connect to");
	gru_cli_option_help("log-level", "l",
		"runs in the given verbose (info, stat, debug, etc) level mode");
	gru_cli_option_help("log-dir", "L", 
		"a directory to save the logs (mandatory for --daemon)");
}


int main(int argc, char **argv) {
	int c;
	int option_index = 0;

	options_t *options = options_new();
	set_options_object(options);

	gru_status_t status = gru_status_new();

	if (!options) {
		return EXIT_FAILURE;
	}

	if (argc < 2) {
		show_help(argv);

		return EXIT_FAILURE;
	}

	gru_logger_set(gru_logger_default_printer);

	while (1) {

		static struct option long_options[] = {
			{"log-level", true, 0, 'l'},
			{"log-dir", true, 0, 'L'},
			{"maestro-url", true, 0, 'm'},
			{"help", false, 0, 'h'},
			{0, 0, 0, 0}};

		c = getopt_long(argc, argv, "L:l:m:h", long_options, &option_index);
		if (c == -1) {
			break;
		}

		switch (c) {
			case 'l':
				options->log_level = gru_logger_get_level(optarg);
				gru_logger_set_mininum(options->log_level);
				break;
			case 'L':
				strncpy(options->logdir, optarg, sizeof(options->logdir) - 1);
				break;
			case 'm':
				options->maestro_uri = gru_uri_parse(optarg, &status);
				if (gru_status_error(&status)) {
					fprintf(stderr, "%s", status.message);
					goto err_exit;
				}
				break;
			case 'h':
				show_help(argv);
				return EXIT_SUCCESS;
			default:
				printf("Invalid or missing option\n");
				show_help(argv);
				return EXIT_SUCCESS;
		}
	}

	init_controller(true, options->logdir, "mpt-receiver-daemon");
	receiverd_worker_start(options);

	options_destroy(&options);
	return EXIT_SUCCESS;

err_exit:
	options_destroy(&options);
	return EXIT_FAILURE;
}
{'fraction_non_alphanumeric': 0.13736263736263737, 'fraction_numerical': 0.008634222919937205, 'mean_word_length': 3.776944704779756, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1980961', 'n_tokens_mistral': 1990, 'n_tokens_neox': 1779, 'n_words': 488}