CmdOpts: merge -[i|a|e] into one -s option
We augmented the grammar to specify the type of device (intero, extro or actuator) so we can now collapse the 3 dev spec cmd line opts into 1 opt.
This commit is contained in:
@@ -17,9 +17,7 @@ public:
|
||||
std::string getUsage() const;
|
||||
|
||||
public:
|
||||
std::vector<std::string> extro;
|
||||
std::vector<std::string> intero;
|
||||
std::vector<std::string> actuator;
|
||||
std::string deviceSpecs;
|
||||
std::vector<std::string> deviceSpecFiles;
|
||||
bool verbose, printUsage;
|
||||
|
||||
|
||||
+11
-35
@@ -6,12 +6,9 @@
|
||||
#include <vector>
|
||||
|
||||
struct option OptionParser::longOptions[] = {
|
||||
{"extro", required_argument, 0, 'e'},
|
||||
{"extrospector", required_argument, 0, 'e'},
|
||||
{"intero", required_argument, 0, 'i'},
|
||||
{"interoceptor", required_argument, 0, 'i'},
|
||||
{"act", required_argument, 0, 'a'},
|
||||
{"actuator", required_argument, 0, 'a'},
|
||||
{"devicespec", required_argument, 0, 's'},
|
||||
{"spec", required_argument, 0, 's'},
|
||||
{"devspec", required_argument, 0, 's'},
|
||||
{"devfile", required_argument, 0, 'd'},
|
||||
{"devicefile", required_argument, 0, 'd'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
@@ -25,18 +22,15 @@ void OptionParser::parseArguments(int argc, char *argv[])
|
||||
int optionIndex = 0;
|
||||
optind = 1; // Reset optind to 1 before parsing
|
||||
while ((opt = getopt_long(
|
||||
argc, argv, "e:i:a:d:v?", longOptions, &optionIndex)) != -1)
|
||||
argc, argv, "s:d:v?", longOptions, &optionIndex)) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'e':
|
||||
extro.push_back(optarg);
|
||||
break;
|
||||
case 'i':
|
||||
intero.push_back(optarg);
|
||||
break;
|
||||
case 'a':
|
||||
actuator.push_back(optarg);
|
||||
case 's':
|
||||
if (!deviceSpecs.empty()) {
|
||||
deviceSpecs += "||";
|
||||
}
|
||||
deviceSpecs += std::string(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
deviceSpecFiles.push_back(optarg);
|
||||
@@ -55,9 +49,7 @@ void OptionParser::parseArguments(int argc, char *argv[])
|
||||
|
||||
std::string OptionParser::getUsage() const
|
||||
{
|
||||
return "Usage: program [-e|--extro|--extrospector <sensor_dev_spec>] "
|
||||
"[-i|--intero|--interoceptor <sensor_dev_spec>] "
|
||||
"[-a|--act|--actuator <actuator_dev_spec>] "
|
||||
return "Usage: program [-s|--devicespec|--spec|--devspec <device_spec>] "
|
||||
"[-d|--devfile|--devicefile <filename>] "
|
||||
"[-v|--verbose] "
|
||||
"[-?|--help]";
|
||||
@@ -69,23 +61,7 @@ void OptionParser::dumpOptions() const
|
||||
std::cout << "Verbose mode is on" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "Extro: ";
|
||||
for (const auto& extro : extro) {
|
||||
std::cout << extro << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "Intero: ";
|
||||
for (const auto& intero : intero) {
|
||||
std::cout << intero << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "Actuator: ";
|
||||
for (const auto& actuator : actuator) {
|
||||
std::cout << actuator << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
std::cout << "Device Specs: " << deviceSpecs << std::endl;
|
||||
|
||||
std::cout << "Device Spec Files: ";
|
||||
for (const auto& file : deviceSpecFiles) {
|
||||
|
||||
Reference in New Issue
Block a user