summaryrefslogtreecommitdiff
path: root/src/options/options.c
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-03-21 11:22:52 -0500
committersanine-a <sanine.not@pm.me>2023-03-21 11:22:52 -0500
commit78eb15d59190c079b1edb405eeae6696724f1b2e (patch)
tree19341cac36443766950d1483952074068d0609b4 /src/options/options.c
parent184a9517a619c0052aabd8ad6ab00ed0d2607e97 (diff)
move modules.h -> common.h and add version numbers
Diffstat (limited to 'src/options/options.c')
-rw-r--r--src/options/options.c23
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;
}