version switch works properly now.
version has precedence over help as well as over missing parameters.
This commit is contained in:
parent
f307656bda
commit
cb1f4fffd9
1 changed files with 12 additions and 5 deletions
|
@ -75,12 +75,19 @@ namespace {
|
||||||
boost::program_options::store(boost::program_options::command_line_parser(parArgc, parArgv).options(commandLine).positional(positionals).run(), parVarMap);
|
boost::program_options::store(boost::program_options::command_line_parser(parArgc, parArgv).options(commandLine).positional(positionals).run(), parVarMap);
|
||||||
boost::program_options::notify(parVarMap);
|
boost::program_options::notify(parVarMap);
|
||||||
bool shownSomething = false;
|
bool shownSomething = false;
|
||||||
if (parVarMap.count("help") or parVarMap.count("source-lang") != 1 or
|
|
||||||
parVarMap.count("dest-lang") != 1 or parVarMap.count("word") == 0) {
|
if (parVarMap.count("version") == 0) {
|
||||||
std::cout << desc << "\n";
|
const bool enoughParams = static_cast<bool>(
|
||||||
shownSomething = true;
|
parVarMap.count("source-lang") == 1 and
|
||||||
|
parVarMap.count("dest-lang") == 1 and
|
||||||
|
parVarMap.count("word") > 0
|
||||||
|
);
|
||||||
|
if (parVarMap.count("help") or not enoughParams) {
|
||||||
|
std::cout << desc << "\n";
|
||||||
|
shownSomething = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (parVarMap.count("version")) {
|
else {
|
||||||
std::cout << APP_NAME << " v" << APP_VER_MAJOR << "." << APP_VER_MINOR << "." << APP_VER_REVISION << "\n";
|
std::cout << APP_NAME << " v" << APP_VER_MAJOR << "." << APP_VER_MINOR << "." << APP_VER_REVISION << "\n";
|
||||||
std::cout << "rev: " << APP_VER_GIT << "\n";
|
std::cout << "rev: " << APP_VER_GIT << "\n";
|
||||||
shownSomething = true;
|
shownSomething = true;
|
||||||
|
|
Loading…
Reference in a new issue