From 3517473605f2747a78a73536a9d79ebc254ce3b3 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Tue, 21 Nov 2023 19:06:12 +0300 Subject: [PATCH] make use of C-Argh library (#5) --- src/template.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/template.c b/src/template.c index 2d97179..1cf0e6e 100644 --- a/src/template.c +++ b/src/template.c @@ -7,6 +7,9 @@ #include #include +// libraries +#include "../lib/c-argh/argh.h" + // constants #if defined(_WIN32) # define __ANSI_CLEAR_STRING "\r" @@ -85,14 +88,17 @@ bytebeat(long double w) ; } +#define USAGE "render_bytebeat [-s | --silent] [-d | --debug]" + int main(int argc, char** argv) { // * parse CLI arguments - silent_mode = argc > 1 && argv[1] != NULL && - (!strcmp(argv[1], "-s") || !strcmp(argv[1], "--silent")); - debug_mode = argc > 1 && argv[1] != NULL && - (!strcmp(argv[1], "-d") || !strcmp(argv[1], "--debug")); + ARGH_PARSE { + ARGH_NEXT(); + if ARGH_BOOL("-s", "--silent") { silent_mode = true; } + else if ARGH_BOOL("-d", "--debug") { debug_mode = true; } + } // * log -> welcome printf(":: C bytebeat generator runtime unit\n");