From 4437d5b3c3eea76f6e2b0fd4a2ba21c02a098aeb Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Sat, 8 Mar 2025 15:21:28 +0900 Subject: updates --- dwmblocks/src/cli.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 dwmblocks/src/cli.c (limited to 'dwmblocks/src/cli.c') diff --git a/dwmblocks/src/cli.c b/dwmblocks/src/cli.c new file mode 100644 index 0000000..b1849ec --- /dev/null +++ b/dwmblocks/src/cli.c @@ -0,0 +1,33 @@ +#include "cli.h" + +#include +#include +#include +#include + +cli_arguments cli_parse_arguments(const char *const argv[], const int argc) { + errno = 0; + cli_arguments args = { + .is_debug_mode = false, + }; + + int opt = -1; + opterr = 0; // Suppress getopt's built-in invalid opt message + while ((opt = getopt(argc, (char *const *)argv, "dh")) != -1) { + switch (opt) { + case 'd': + args.is_debug_mode = true; + break; + case '?': + (void)fprintf(stderr, "error: unknown option `-%c'\n", optopt); + // fall through + case 'h': + // fall through + default: + (void)fprintf(stderr, "usage: %s [-d]\n", BINARY); + errno = 1; + } + } + + return args; +} -- cgit v1.2.3