fix: versioning

This commit is contained in:
Tobias Reisinger 2020-06-17 01:52:06 +02:00
parent 4d28033073
commit 486b45c680
3 changed files with 18 additions and 7 deletions
src/helpers

View file

@ -6,6 +6,7 @@
#include <config.h>
#include <logger.h>
#include <helpers.h>
#include <version.h>
static const char *const usage[] = {
"core [options] [[--] args]",
@ -16,12 +17,13 @@ static const char *const usage[] = {
void
helper_parse_cli(int argc, const char **argv, config_t *config)
{
int version = 0;
struct argparse_option options[] =
{
OPT_HELP(),
OPT_GROUP("Basic options"),
OPT_STRING('c', "config", &config->file, "path to config file", NULL, 0, OPT_NONEG),
OPT_BOOLEAN('v', "version", &version, "print version", NULL, 0, OPT_NONEG),
OPT_END(),
};
@ -34,6 +36,12 @@ helper_parse_cli(int argc, const char **argv, config_t *config)
);
argc = argparse_parse(&argparse, argc, argv);
if(version)
{
printf("%s\n", EMGAUWA_CORE_VERSION);
exit(0);
}
if(argc == 1)
{
config->run_type = RUN_TYPE_INVALID;