summaryrefslogblamecommitdiffstats
path: root/src/command_line_options.cpp
blob: 3a133ba16ad679cc9498e46324550e38b0968d6f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                                                       
                                                        
                                                      





                                                        
                                                      




                            
                                                                                               















                                                     


                                            


                                              














                                                 


                                                    


                                             
                  


         
#include "command_line_options.h"
#include <getopt.h>
#include <QDebug>

CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) {
    // parse command line arguments
	static const struct option longOptions[] = {
		{"config", required_argument, NULL, 'c'},
		{"default", required_argument, NULL, 'd'},
		{"env", required_argument, NULL, 'e'},
		{"file", required_argument, NULL, 'f'},
		{"xpath", required_argument, NULL, 'x'},
		{"url", required_argument, NULL, 'u'},
		{"size", required_argument, NULL, 's'},
		{"theme", required_argument, NULL, 't'},
		{"pvs", no_argument, NULL, 'b'},
		{"debug", no_argument, NULL, 'D'},
		{"version", no_argument, NULL, 'v'},
		{"help", no_argument, NULL, 'h'},
		{"runscript", no_argument, NULL, 'S'},
		{0, 0, 0, 0}
	};

	int c;

    while ((c = getopt_long(argc, argv, "c:d:e:f:x:u:s:t:w:vhbDS", longOptions, NULL)) != -1) {
        switch (c) {
        case 'c':
            options.insert("config", optarg);
            break;
        case 'd':
            options.insert("default", optarg);
            break;
        case 'f':
            options.insert("file", optarg);
            break;
        case 'D':
            options.insert("debugMode", "debugMode");
            break;
        case 'e':
            options.insert("env", optarg);
            break;
        case 'x':
            options.insert("xpath", optarg);
            break;
        case 'u':
        	options.insert("url", optarg);
        	break;
        case 's':
            options.insert("size", optarg);
            break;
        case 't':
            options.insert("theme", optarg);
            break;
        case 'b':
            options.insert("pvs", "pvs");
            break;
        case 'v':
            options.insert("version", "version");
            break;
        case 'h':
            options.insert("usage", "usage");
            break;
        case 'S':
        	options.insert("runscript", optarg);
        	break;
        case '?':
        default:
            options.insert("error", "error");
            break;
        }
    }
}