summaryrefslogtreecommitdiffstats
path: root/src/CommandLineOptions.cpp
blob: 06b00aeea2bc47e3ddc1eaca3a5488c9087f6fa7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 * This class parses the command line options.
 */


#include <getopt.h>
#include <cstdlib>
#include "CommandLineOptions.h"

CommandLineOptions::CommandLineOptions(int argc, char * const argv[]){
	// Parse command line arguments.
	int longIndex = 0;
	// TODO: clean output...
	static const char *optString = "uh";
	static const struct option longOpts[] =
	{
	    // If an option requires parameters, write this number instead of no_argument.
	    // The last argument, is the corresponding char to the option string.
		{"url", required_argument, NULL, 'u'},
		{"help", no_argument, NULL, 'h'}
	};
	// getopt_long returns the index of the next argument to be read, -1 if there are no more arguments.
	int opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
	while (opt != -1)
	{
		switch(opt)
	    {
	    case 'u':
	    	options.insert("url", optarg);
	        break;
	    case 'h':
	    	//printUsage();
	    	break;
	    }
	    opt = getopt_long(argc, argv, optString, longOpts, &longIndex);
	}
}

CommandLineOptions::~CommandLineOptions(){

}