diff options
author | Nils Schwabe | 2014-03-03 15:14:20 +0100 |
---|---|---|
committer | Nils Schwabe | 2014-03-03 15:14:20 +0100 |
commit | 030d91e628a2ecd5634376c9c4d903a1fa0fb423 (patch) | |
tree | 227029e3b48deb1d4d01ce497d9ec3b8d47f7a61 /src/command_line_options.cpp | |
parent | Initial commit (diff) | |
download | vmchooser2-030d91e628a2ecd5634376c9c4d903a1fa0fb423.tar.gz vmchooser2-030d91e628a2ecd5634376c9c4d903a1fa0fb423.tar.xz vmchooser2-030d91e628a2ecd5634376c9c4d903a1fa0fb423.zip |
added files from vmchooser1
Diffstat (limited to 'src/command_line_options.cpp')
-rw-r--r-- | src/command_line_options.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/command_line_options.cpp b/src/command_line_options.cpp new file mode 100644 index 0000000..1cf1194 --- /dev/null +++ b/src/command_line_options.cpp @@ -0,0 +1,68 @@ +#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'}, + {"path", required_argument, NULL, 'p'}, + {"xpath", required_argument, NULL, 'x'}, + {"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'}, + {0, 0, 0, 0} + }; + + int c; + + while ((c = getopt_long(argc, argv, "c:d:e:f:p:x:s:t:w:vhbD", 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 'p': + options.insert("path", optarg); + break; + case 'x': + options.insert("xpath", 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 '?': + default: + options.insert("error", "error"); + } + } +} |