WIP: cli args
authorLukas Krickl <lukas@krickl.dev>
Sun, 5 Nov 2023 05:54:50 +0000 (06:54 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 5 Nov 2023 05:54:50 +0000 (06:54 +0100)
doc/ulas.man
include/ulas.h
src/main.c

index 9360001a5edbcc5902730d68ecb2e7b470bb1d5b..f7dbcdbe3a0f45ae8238e534adf1ffe0f0f22b88 100644 (file)
@@ -1,22 +1,26 @@
 .\" Manpage for ulas.
 .\" Contact lukas@krickl.dev to correct errors or typos.
 
-.TH man 8 "21 August 2023" "0.0.1" "ulas manual"
+.TH man 1 "21 August 2023" "0.0.1" "ulas manual"
 
 .SH NAME
   ulas
 .SH SYNOPSIS
-  ulas [-v] [--help] [--version]
+  ulas [-hvV] 
 .SH DESCRIPTION
   ulas
 
-  --help                    
+  -h                    
     display this help and exit
-  --version                 
+  -v                 
     display version info and exit
   -v, --verbose             
     verbose output
-  
+.SH SYNTAX
+
+
+
 .SH EXAMPLES
  
 .SH SEE ALSO
index d7d3caab7b7bf2ab99dcf5ad8af8a337678e9889..f916a91f2918b272c14af582dfa99ccf016f88d0 100644 (file)
@@ -9,8 +9,6 @@
 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
 
-#define ULAS_COMMENT ';'
-
 // Config variables
 #define ULAS_CFG_FMT_GREEN "\x1B[32m"
 #define ULAS_CFG_FMT_YELLOW "\x1B[33m"
 #define ULAS_CFG_FMT_BLUE "\x1B[34m"
 #define ULAS_CFG_FMT_RESET "\x1B[0m"
 
+// configurable tokens
+#define ULAS_TOK_COMMENT ';'
+#define ULAS_TOK_DIRECTIVE_BEGIN '#'
+
 // format macros
 #define ULAS_FMT(f, fmt)                                                       \
   if (isatty(fileno(f)) && ulascfg.color) {                                    \
index 9b2f4ee2e7ef32a3d8312617aad1d2d378c44af9..d591da66f41c10f4322f76b040bc13e8e05a063b 100644 (file)
@@ -8,19 +8,27 @@
 #define ULAS_NAME "ulas"
 #define ULAS_VER "0.0.1"
 
+// args without value
+#define ULAS_OPTS "hvV"
+
+// args with value
+#define ULAS_OPTS_ARG ""
+
+#define ULAS_HELP(a, desc) printf("\t%s\t%s\n", (a), desc);
+
 void ulas_help(void) {
   printf("%s\n", ULAS_NAME);
-  printf("Usage %s [-h] [-V] [-v]\n\n", ULAS_NAME);
-  printf("\t-h\tdisplay this help and exit\n");
-  printf("\t-V\tdisplay version info and exit\n");
-  printf("\t-v\tverbose output\n");
+  printf("Usage %s [-%s]\n\n", ULAS_NAME, ULAS_OPTS);
+  ULAS_HELP("-h", "display this help and exit");
+  ULAS_HELP("-V", "display version info and exit");
+  ULAS_HELP("-v", "verbose output");
 }
 
 void ulas_version(void) { printf("%s version %s\n", ULAS_NAME, ULAS_VER); }
 
 void ulas_getopt(int argc, char **argv, struct ulas_config *cfg) {
   int c = 0;
-  while ((c = getopt(argc, argv, "hvV")) != -1) {
+  while ((c = getopt(argc, argv, ULAS_OPTS ULAS_OPTS_ARG)) != -1) {
     switch (c) {
     case 'h':
       ulas_help();