diff --git a/smocore/marionette/marionette.cpp b/smocore/marionette/marionette.cpp index 5117d06..285c0eb 100644 --- a/smocore/marionette/marionette.cpp +++ b/smocore/marionette/marionette.cpp @@ -46,7 +46,7 @@ void ComponentThread::marionetteMain(ComponentThread& self) catch (const std::invalid_argument& e) { std::cerr << __func__ << ": Exception occurred: " << e.what() - << '\n' << options.getUsage() << '\n'; + << '\n'; options.printUsage = true; mrntt::exitCode = EXIT_FAILURE; diff --git a/smocore/opts.cpp b/smocore/opts.cpp index 42fc14e..d849804 100644 --- a/smocore/opts.cpp +++ b/smocore/opts.cpp @@ -22,7 +22,7 @@ struct option OptionParser::longOptions[] = { {"apipath", required_argument, 0, 'p'}, {"libpath", required_argument, 0, 'p'}, {"verbose", no_argument, 0, 'v'}, - {"help", no_argument, 0, '?'}, + {"help", no_argument, 0, 'h'}, {0, 0, 0, 0} }; @@ -35,8 +35,9 @@ void OptionParser::parseArguments(int argc, char *argv[], char **envp) argv0 = argv[0]; optind = 1; // Reset optind to 1 before parsing + opterr = 0; while ((opt = getopt_long( - argc, argv, "s:d:a:p:v?", longOptions, &optionIndex)) != -1) + argc, argv, "s:d:a:p:vh?", longOptions, &optionIndex)) != -1) { switch (opt) { @@ -69,10 +70,10 @@ void OptionParser::parseArguments(int argc, char *argv[], char **envp) case 'v': verbose = true; break; - case '?': + case 'h': printUsage = true; return; - default: + case '?': throw std::invalid_argument( std::string(__func__) + " - Invalid argument encountered: " + std::string(argv[optind - 1])); @@ -87,7 +88,7 @@ std::string OptionParser::getUsage() const "[-a|--api-lib|--apilib|--api|--lib ] " "[-p|--api-lib-path|--apipath|--libpath ] " "[-v|--verbose] " - "[-?|--help]"; + "[-h|--help]"; } std::string OptionParser::stringifyOptions(void) const