diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2025-07-31 11:52:42 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2025-07-31 11:52:42 +0530 |
commit | fa380e1c35f403e2530bd6ffebe3a4881080a391 (patch) | |
tree | e2e7b163d2c7c9283e28c3c0ded053b3ea0fb27e | |
parent | 9aea7ab4daf9097225f46788fb87125c0b51076e (diff) |
msg: add option to increase verbosity
-rw-r--r-- | include/msg.h | 3 | ||||
-rw-r--r-- | src/main.c | 9 | ||||
-rw-r--r-- | src/msg.c | 4 |
3 files changed, 12 insertions, 4 deletions
diff --git a/include/msg.h b/include/msg.h index f15d9c9..4f44bf0 100644 --- a/include/msg.h +++ b/include/msg.h @@ -19,6 +19,8 @@ #ifndef __MSG_H #define __MSG_H +#include <stdbool.h> + #define PARTIALS "partials" #define TEMPLATES "templates" #define BASE_TEMPLATE "base.html" @@ -27,6 +29,7 @@ typedef struct { char *base_directory; char *output_directory; + bool verbose; } msg_t; int run(void); @@ -33,9 +33,10 @@ msg_t *msg; void usage(char *program) { - printf("Usage: %s [-h] [-w] [-o <output>] <directory>\n", program); + printf("Usage: %s [-h] [-w] [-v] [-o <output>] <directory>\n", program); printf("\t-h : Help\n"); printf("\t-w : Watch working directory for changes\n"); + printf("\t-v : Verbose\n"); printf("\t-o <output>: Output directory\n"); printf("\t<directory>: Working directory\n"); } @@ -58,8 +59,9 @@ main(int argc, char **argv) msg = malloc(sizeof(msg_t)); msg->base_directory = "."; msg->output_directory = "dist"; + msg->verbose = false; - while ((opt = getopt(argc, argv, "o:hw")) != -1) { + while ((opt = getopt(argc, argv, "o:hvw")) != -1) { switch (opt) { case 'o': msg->output_directory = optarg; @@ -67,6 +69,9 @@ main(int argc, char **argv) case 'w': watch = true; break; + case 'v': + msg->verbose = true; + break; case 'h': default: usage(argv[0]); @@ -181,9 +181,9 @@ run(void) for (size_t i = 0; i < resources->size; i++) { ptr_wrapper_t *value = list_get(resources, i); char *path = value->ptr; - if (i < LOG_THRESHOLD) + if (i < LOG_THRESHOLD || msg->verbose) printf("\tProcessing %s\n", path); - else if (i == LOG_THRESHOLD) + else if (i == LOG_THRESHOLD && !msg->verbose) printf("\t...\n"); handle_file(path); |