Navigation Menu

Skip to content

Commit

Permalink
tesseractmain: Allow combinations of the different help options
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jun 2, 2018
1 parent 724a72a commit 629ded2
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions src/api/tesseractmain.cpp
Expand Up @@ -272,35 +272,28 @@ static void ParseArgs(const int argc, char** argv, const char** lang,
GenericVector<STRING>* vars_values, int* arg_i,
tesseract::PageSegMode* pagesegmode,
tesseract::OcrEngineMode* enginemode) {
if (argc == 2) {
if ((strcmp(argv[1], "-h") == 0) || (strcmp(argv[1], "--help") == 0)) {
PrintHelpMessage(argv[0]);
exit(EXIT_SUCCESS);
}
if (strcmp(argv[1], "--help-extra") == 0) {
PrintHelpExtra(argv[0]);
exit(EXIT_SUCCESS);
}
if ((strcmp(argv[1], "--help-psm") == 0)) {
PrintHelpForPSM();
exit(EXIT_SUCCESS);
}
if ((strcmp(argv[1], "--help-oem") == 0)) {
PrintHelpForOEM();
exit(EXIT_SUCCESS);
}
if ((strcmp(argv[1], "-v") == 0) || (strcmp(argv[1], "--version") == 0)) {
PrintVersionInfo();
exit(EXIT_SUCCESS);
}
}

bool noocr = false;
int i;
for (i = 1; i < argc && (*outputbase == nullptr || argv[i][0] == '-'); i++) {
if (*image != nullptr && *outputbase == nullptr) {
// outputbase follows image, don't allow options at that position.
*outputbase = argv[i];
} else if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) {
PrintHelpMessage(argv[0]);
noocr = true;
} else if (strcmp(argv[i], "--help-extra") == 0) {
PrintHelpExtra(argv[0]);
noocr = true;
} else if ((strcmp(argv[i], "--help-psm") == 0)) {
PrintHelpForPSM();
noocr = true;
} else if ((strcmp(argv[i], "--help-oem") == 0)) {
PrintHelpForOEM();
noocr = true;
} else if ((strcmp(argv[i], "-v") == 0) ||
(strcmp(argv[i], "--version") == 0)) {
PrintVersionInfo();
noocr = true;
} else if (strcmp(argv[i], "-l") == 0 && i + 1 < argc) {
*lang = argv[i + 1];
++i;
Expand Down Expand Up @@ -443,6 +436,9 @@ int main(int argc, char** argv) {
&print_parameters, &vars_vec, &vars_values, &arg_i, &pagesegmode,
&enginemode);

if (image == nullptr && !list_langs)
return EXIT_SUCCESS;

bool banner = false;
if (outputbase != nullptr && strcmp(outputbase, "-") &&
strcmp(outputbase, "stdout")) {
Expand Down

0 comments on commit 629ded2

Please sign in to comment.