diff options
author | Håvard Pettersen <havardpe@oath.com> | 2022-03-31 11:44:10 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@oath.com> | 2022-04-01 10:24:32 +0000 |
commit | d71f76a73fe54558f613e75a3a8cfd70fc46a7e8 (patch) | |
tree | 7d170e5b792dbf5fed06ff7c7b2db398b6cb64c7 /configutil | |
parent | 1bb3dd192f4bcb91e710fe19ca54b2b8935ffb83 (diff) |
use getopt/getopt_long directly
Diffstat (limited to 'configutil')
-rw-r--r-- | configutil/src/apps/configstatus/main.cpp | 13 | ||||
-rw-r--r-- | configutil/src/apps/modelinspect/main.cpp | 13 |
2 files changed, 12 insertions, 14 deletions
diff --git a/configutil/src/apps/configstatus/main.cpp b/configutil/src/apps/configstatus/main.cpp index 3656013cf2e..6233a9d9bb5 100644 --- a/configutil/src/apps/configstatus/main.cpp +++ b/configutil/src/apps/configstatus/main.cpp @@ -6,6 +6,7 @@ #include <vespa/config/subscription/sourcespec.h> #include <vespa/fastos/app.h> #include <iostream> +#include <unistd.h> #include <vespa/log/log.h> LOG_SETUP("vespa-config-status"); @@ -34,24 +35,22 @@ Application::~Application() { } int Application::parseOpts() { int c = '?'; - const char *optArg = NULL; - int optInd = 0; - while ((c = GetOpt("c:s:vC:f:", optArg, optInd)) != -1) { + while ((c = getopt(_argc, _argv, "c:s:vC:f:")) != -1) { switch (c) { case 'v': _flags.verbose = true; break; case 'C': - _cfgId = optArg; + _cfgId = optarg; break; case 'c': - _specString = optArg; + _specString = optarg; break; case 'h': usage(); std::_Exit(0); case 'f': - _flags.host_filter = parse_host_set(optArg); + _flags.host_filter = parse_host_set(optarg); break; default: usage(); @@ -61,7 +60,7 @@ int Application::parseOpts() { if (_specString.empty()) { _specString = getSources(); } - return optInd; + return optind; } HostFilter Application::parse_host_set(vespalib::stringref raw_arg) const { diff --git a/configutil/src/apps/modelinspect/main.cpp b/configutil/src/apps/modelinspect/main.cpp index 7053adf17fa..84893ffdf07 100644 --- a/configutil/src/apps/modelinspect/main.cpp +++ b/configutil/src/apps/modelinspect/main.cpp @@ -6,6 +6,7 @@ #include <vespa/config/subscription/sourcespec.h> #include <vespa/fastos/app.h> #include <iostream> +#include <unistd.h> #include <vespa/log/log.h> LOG_SETUP("vespa-model-inspect"); @@ -33,9 +34,7 @@ int Application::parseOpts() { int c = '?'; - const char *optArg = NULL; - int optInd = 0; - while ((c = GetOpt("hvut:c:C:", optArg, optInd)) != -1) { + while ((c = getopt(_argc, _argv, "hvut:c:C:")) != -1) { switch (c) { case 'v': _flags.verbose = true; @@ -44,14 +43,14 @@ Application::parseOpts() _flags.makeuri = true; break; case 't': - _flags.tagFilter.push_back(optArg); + _flags.tagFilter.push_back(optarg); _flags.tagfilt = true; break; case 'C': - _cfgId = optArg; + _cfgId = optarg; break; case 'c': - _specString = optArg; + _specString = optarg; break; case 'h': return _argc; @@ -63,7 +62,7 @@ Application::parseOpts() if (_specString.empty()) { _specString = getSources(); } - return optInd; + return optind; } vespalib::string |