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