From 78ee0de29b46f5faed6ca2ae5222c64fbd9a2c1e Mon Sep 17 00:00:00 2001 From: sanine Date: Tue, 4 Jan 2022 23:18:10 -0600 Subject: allow overriding the builtin script --- src/options.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/options.c') diff --git a/src/options.c b/src/options.c index cab8079..fa6b999 100644 --- a/src/options.c +++ b/src/options.c @@ -6,10 +6,11 @@ static void print_usage(const char *progname) { - printf("Usage: %s [-c config_file] [-v[v[v]]] [-q[q[q]]] [-h]\n" + printf("Usage: %s [-c config_file] [-v[v[v]]] [-q[q[q]]] [-h] [-s script]\n" " -v Increase output verbosity (-vvv displays every log message)\n" " -q Decrease output verbosity (-qqq suppresses even fatal errors)\n" " -c Specify configuration file to read (default 'config.lua')\n" + " -s Override the built-in Lua script\n" " -h Print this help message and exit\n", progname); } @@ -18,9 +19,10 @@ int parse_options(struct argent_options *opts, int argc, char **argv) { opts->log_level = WARN; opts->conf_filename = "config.lua"; + opts->script_filename = NULL; int opt; - while ((opt = getopt(argc, argv, "hqvc:")) != -1) { + while ((opt = getopt(argc, argv, "hqvc:s:")) != -1) { switch (opt) { case 'q': opts->log_level -= 1; @@ -34,6 +36,10 @@ int parse_options(struct argent_options *opts, int argc, char **argv) opts->conf_filename = optarg; break; + case 's': + opts->script_filename = optarg; + break; + case 'h': print_usage(argv[0]); return 2; -- cgit v1.2.1