cmd:opts: Now set OptionParser::argv0 to argv[0]

This commit is contained in:
2025-01-08 15:07:42 -04:00
parent 090f0d3b02
commit 1178970728
2 changed files with 5 additions and 1 deletions
+1
View File
@@ -23,6 +23,7 @@ public:
}
public:
std::string argv0;
std::string senseApiLibPath;
std::vector<std::string> senseApiLibs;
std::string deviceSpecs;
+4 -1
View File
@@ -25,6 +25,9 @@ void OptionParser::parseArguments(int argc, char *argv[])
{
int opt;
int optionIndex = 0;
argv0 = argv[0];
optind = 1; // Reset optind to 1 before parsing
while ((opt = getopt_long(
argc, argv, "s:d:a:p:v?", longOptions, &optionIndex)) != -1)
@@ -80,7 +83,7 @@ void OptionParser::parseArguments(int argc, char *argv[])
std::string OptionParser::getUsage() const
{
return "Usage: program [-s|--devicespec|--spec|--devspec <device_spec>] "
return "Usage: " + argv0 + " [-s|--devicespec|--spec|--devspec <device_spec>] "
"[-d|--devfile|--devicefile <filename>] "
"[-a|--sense-api-lib|--senseapi <filename>] "
"[-p|--sense-api-path <directory>] "