]> git.itanic.dy.fi Git - glucose/blobdiff - options.c
Added -format option (defaults to "clean"), added "raw" and "CSV" formats.
[glucose] / options.c
index 9d4ff032ed5c311beb29a3cd93eb8cbb8a7b9b60..7bd5b9bbfd9700a081a8753d46dc379c01903bf2 100644 (file)
--- a/options.c
+++ b/options.c
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 
 #include "options.h"
+#include "utils.h"
 
 int read_args(int argc, char *argv[], struct user_options *opts)
 {
@@ -30,8 +31,9 @@ int read_args(int argc, char *argv[], struct user_options *opts)
                 { .val = 'd', .name = "device", .has_arg = 1, },
                 { .val = 'v', .name = "verbose", .has_arg = 2 },
                { .val = 'o', .name = "output", .has_arg = 1 },
+                { .val = 'f', .name = "format", .has_arg = 1, },
         };
-        char short_options[] = "d:v:o:";
+        char short_options[] = "d:v:o:f:";
 
        memset(opts, 0, sizeof(*opts));
 
@@ -54,6 +56,20 @@ int read_args(int argc, char *argv[], struct user_options *opts)
                case 'o':
                        opts->output_path = optarg;
                        break;
+               case 'f':
+                       if ( strcmp(optarg, "raw") == 0 ) {
+                               opts->output_format = RAW;
+                       } else
+                       if ( strcmp(optarg, "clean") == 0 ) {
+                               opts->output_format = CLEAN;
+                       } else
+                       if ( strcmp(optarg, "csv") == 0 ) {
+                               opts->output_format = CSV;
+                       } else {
+                               trace(0, "Unknown format type \"%s\", must be one of \"raw\", \"clean\", or \"csv\"\n", optarg );
+                               return -1;
+                       }
+                       break;
                 case '?':
                        return -1;
                 }