diff options
author | sanine <sanine.not@pm.me> | 2022-01-01 13:24:33 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-01-01 13:24:33 -0600 |
commit | 7b78b6986e714cbd7653b89287b928974eb5ee4f (patch) | |
tree | b6334336f722e44bf3020e316976ed5ed3b85ba0 /src/options.c |
initial commit
Diffstat (limited to 'src/options.c')
-rw-r--r-- | src/options.c | 35 |
1 files changed, 35 insertions, 0 deletions
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 <stdio.h> +#include <unistd.h> + +#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; +} |