From 7b78b6986e714cbd7653b89287b928974eb5ee4f Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 1 Jan 2022 13:24:33 -0600 Subject: initial commit --- src/options.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/options.c (limited to 'src/options.c') diff --git a/src/options.c b/src/options.c new file mode 100644 index 0000000..b3836a7 --- /dev/null +++ b/src/options.c @@ -0,0 +1,35 @@ +#include +#include + +#include "options.h" + +static void print_usage(const char *progname) +{ + printf("Usage: %s [-c config_file] [-o output_directory]\n", + progname); +} + +int parse_options(struct argent_options *opts, int argc, char **argv) +{ + opts->conf_filename = "argent.lua"; + opts->output_dir = "build"; + + int opt; + while ((opt = getopt(argc, argv, "c:o:")) != -1) { + switch (opt) { + case 'c': + opts->conf_filename = optarg; + break; + + case 'o': + opts->output_dir = optarg; + break; + + default: + print_usage(argv[0]); + return 1; + } + } + + return 0; +} -- cgit v1.2.1