diff options
Diffstat (limited to 'src/options/options.c')
-rw-r--r-- | src/options/options.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/options/options.c b/src/options/options.c index 4488837..7ac35c7 100644 --- a/src/options/options.c +++ b/src/options/options.c @@ -1,5 +1,6 @@ #include <stdio.h> #include <cargs.h> +#include <common.h> #include "options.h" static struct cag_option opts[] = { @@ -11,6 +12,13 @@ static struct cag_option opts[] = { .description = "The filename of the main script. (default: main.lua)" }, { + .identifier = 'e', + .access_letters = NULL, + .access_name = "version", + .value_name = NULL, + .description = "Show the honey version" + }, + { .identifier = 'h', .access_letters = "h", .access_name = "help", @@ -29,6 +37,12 @@ void print_help(char *program_name) enum outcomes_t parse_options(struct honey_options *options, int argc, char **argv) { + /* check if we even need to parse at all */ + if (argc == 1) { + print_help(argv[0]); + return EXIT_SUCCESS; + } + /* default values */ options->script_file = "main.lua"; @@ -47,6 +61,15 @@ enum outcomes_t parse_options(struct honey_options *options, int argc, char **ar case 'h': print_help(argv[0]); return EXIT_SUCCESS; + case 'e': + printf( + "honey v%d.%d.%d -- %s\n", + HONEY_VERSION_MAJOR, + HONEY_VERSION_MINOR, + HONEY_VERSION_PATCH, + HONEY_VERSION_STR + ); + return EXIT_SUCCESS; default: return EXIT_FAILURE; } |