diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2025-07-30 13:56:13 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2025-07-30 13:56:13 +0530 |
commit | 13f18ecfb05fb572b6f30364b570023661977ebb (patch) | |
tree | 153309290bca5ac6b731879c505f98bf8a9d437b /src/main.c | |
parent | 01ef152082e4e396b4b5510aab642cf6235bc59d (diff) |
main: use getopt() to parse arguments
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -19,9 +19,43 @@ #define _GNU_SOURCE #include <msg.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +msg_t *msg; + +void +usage(char *program) +{ + printf("Usage: %s [-o <output>] [-h] <directory>\n", program); + printf("\t-o <output>: Output directory\n"); + printf("\t-h : Help\n"); + printf("\t<directory>: Working directory\n"); +} int main(int argc, char **argv) { - return run(argc, argv); + int opt; + msg = malloc(sizeof(msg_t)); + + while ((opt = getopt(argc, argv, "o:h")) != -1) { + switch (opt) { + case 'o': + /* msg.output_directory = optarg; */ + break; + case 'h': + default: + usage(argv[0]); + return EXIT_SUCCESS; + } + } + + msg->base_directory = "compromyse.xyz"; + + int r = run(); + + free(msg); + return r; } |