From 78eb15d59190c079b1edb405eeae6696724f1b2e Mon Sep 17 00:00:00 2001 From: sanine-a Date: Tue, 21 Mar 2023 11:22:52 -0500 Subject: move modules.h -> common.h and add version numbers --- src/options/options.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/options') 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 #include +#include #include "options.h" static struct cag_option opts[] = { @@ -10,6 +11,13 @@ static struct cag_option opts[] = { .value_name = "SCRIPT_FILE", .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", @@ -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; } -- cgit v1.2.1