summaryrefslogtreecommitdiffstats
path: root/src/command_line_options.cpp
diff options
context:
space:
mode:
authorSimon Rettberg2014-05-04 12:56:35 +0200
committerSimon Rettberg2014-05-04 12:56:35 +0200
commit5103900bfeb0feced5b58d68924479bfc73d8ec5 (patch)
tree34a0d8145b6f3585e3cc4ae3a2f5a70e1a5db984 /src/command_line_options.cpp
parentshut up eclipse about missing break (diff)
downloadvmchooser2-5103900bfeb0feced5b58d68924479bfc73d8ec5.tar.gz
vmchooser2-5103900bfeb0feced5b58d68924479bfc73d8ec5.tar.xz
vmchooser2-5103900bfeb0feced5b58d68924479bfc73d8ec5.zip
Lots of fixes, cleanup, refactoring
* Added command line option to set the base path where images can be accessed locally, in case NFS/CIFS is used. * Sorted command line options in source file to make it easier to add new options (prevent accidental shortopt collisions). * Disable "My Courses" button if the list is empty. * Added some TODO notes :>
Diffstat (limited to 'src/command_line_options.cpp')
-rw-r--r--src/command_line_options.cpp57
1 files changed, 31 insertions, 26 deletions
diff --git a/src/command_line_options.cpp b/src/command_line_options.cpp
index 3a133ba..fd946bd 100644
--- a/src/command_line_options.cpp
+++ b/src/command_line_options.cpp
@@ -3,48 +3,57 @@
#include <QDebug>
CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) {
- // parse command line arguments
+ // parse command line arguments (please sort by short option for easier handling)
static const struct option longOptions[] = {
+ {"base", required_argument, NULL, 'b'},
{"config", required_argument, NULL, 'c'},
+ {"debug", no_argument, NULL, 'D'},
{"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'},
+ {"help", no_argument, NULL, 'h'},
+ {"pool", required_argument, NULL, 'P'},
+ {"pvs", no_argument, NULL, 'p'},
+ {"runscript", no_argument, NULL, 'S'},
{"size", required_argument, NULL, 's'},
{"theme", required_argument, NULL, 't'},
- {"pvs", no_argument, NULL, 'b'},
- {"debug", no_argument, NULL, 'D'},
+ {"url", required_argument, NULL, 'u'},
{"version", no_argument, NULL, 'v'},
- {"help", no_argument, NULL, 'h'},
- {"runscript", no_argument, NULL, 'S'},
+ {"xpath", required_argument, NULL, 'x'},
{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) {
+ // Again, please sort alphabetically in getopt_long call and switch statement
+ while ((c = getopt_long(argc, argv, "b:c:Dd:f:hP:pSs:t:u:vx:?", longOptions, NULL)) != -1) {
switch (c) {
+ case 'b':
+ options.insert("base", optarg);
+ break;
case 'c':
options.insert("config", optarg);
break;
+ case 'D':
+ options.insert("debugMode", "debugMode");
+ break;
case 'd':
options.insert("default", optarg);
break;
case 'f':
options.insert("file", optarg);
break;
- case 'D':
- options.insert("debugMode", "debugMode");
+ case 'h':
+ case '?':
+ options.insert("usage", "usage");
break;
- case 'e':
- options.insert("env", optarg);
+ case 'P':
+ options.insert("pool", optarg);
break;
- case 'x':
- options.insert("xpath", optarg);
+ case 'p':
+ options.insert("pvs", "pvs");
break;
- case 'u':
- options.insert("url", optarg);
+ case 'S':
+ options.insert("runscript", optarg);
break;
case 's':
options.insert("size", optarg);
@@ -52,19 +61,15 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) {
case 't':
options.insert("theme", optarg);
break;
- case 'b':
- options.insert("pvs", "pvs");
- break;
+ case 'u':
+ options.insert("url", optarg);
+ break;
case 'v':
options.insert("version", "version");
break;
- case 'h':
- options.insert("usage", "usage");
+ case 'x':
+ options.insert("xpath", optarg);
break;
- case 'S':
- options.insert("runscript", optarg);
- break;
- case '?':
default:
options.insert("error", "error");
break;