Skip to content

Commit

Permalink
Merge pull request #1501 from stweil/cmdline
Browse files Browse the repository at this point in the history
training: Support new command line option -v (short form for --version)
  • Loading branch information
zdenop authored Apr 21, 2018
2 parents 5435c9c + d68ab9f commit 4f56abb
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions training/ambiguous_words.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ int main(int argc, char** argv) {
tesseract::CheckSharedLibraryVersion();

// Parse input arguments.
if (argc > 1 && !strcmp(argv[1], "--version")) {
if (argc > 1 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) {
printf("%s\n", tesseract::TessBaseAPI::Version());
return 0;
} else if (argc != 4 && (argc != 6 || strcmp(argv[1], "-l") != 0)) {
printf("Usage: %s --version | %s [-l lang] tessdata_dir wordlist_file"
printf("Usage: %s -v | --version | %s [-l lang] tessdata_dir wordlist_file"
" output_ambiguous_wordlist_file\n", argv[0], argv[0]);
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion training/combine_tessdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ int main(int argc, char **argv) {

int i;
tesseract::TessdataManager tm;
if (argc > 1 && !strcmp(argv[1], "--version")) {
if (argc > 1 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) {
printf("%s\n", tesseract::TessBaseAPI::Version());
return 0;
} else if (argc == 2) {
Expand Down
4 changes: 3 additions & 1 deletion training/commandlineflags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ void ParseCommandLineFlags(const char* usage,
printf("USAGE: %s\n", usage);
PrintCommandLineFlags();
exit(0);
} else if (*argc > 1 && !strcmp((*argv)[1], "--version")) {
}

if (*argc > 1 && (!strcmp((*argv)[1], "-v") || !strcmp((*argv)[1], "--version"))) {
printf("%s\n", TessBaseAPI::Version());
exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion training/commontraining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void ParseArguments(int* argc, char ***argv) {
STRING usage;
if (*argc) {
usage += (*argv)[0];
usage += " --version | ";
usage += " -v | --version | ";
usage += (*argv)[0];
}
usage += " [.tr files ...]";
Expand Down
4 changes: 2 additions & 2 deletions training/dawg2wordlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ int WriteDawgAsWordlist(const UNICHARSET &unicharset,
int main(int argc, char *argv[]) {
tesseract::CheckSharedLibraryVersion();

if (argc > 1 && !strcmp(argv[1], "--version")) {
if (argc > 1 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) {
printf("%s\n", tesseract::TessBaseAPI::Version());
return 0;
} else if (argc != 4) {
tprintf("Print all the words in a given dawg.\n");
tprintf("Usage: %s --version | %s <unicharset> <dawgfile> <wordlistfile>\n",
tprintf("Usage: %s -v | --version | %s <unicharset> <dawgfile> <wordlistfile>\n",
argv[0], argv[0]);
return 1;
}
Expand Down
4 changes: 2 additions & 2 deletions training/merge_unicharsets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
int main(int argc, char** argv) {
tesseract::CheckSharedLibraryVersion();

if (argc > 1 && !strcmp(argv[1], "--version")) {
if (argc > 1 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) {
printf("%s\n", tesseract::TessBaseAPI::Version());
return 0;
} else if (argc < 4) {
// Print usage
printf("Usage: %s --version |\n"
printf("Usage: %s -v | --version |\n"
" %s unicharset-in-1 ... unicharset-in-n unicharset-out\n",
argv[0], argv[0]);
return 1;
Expand Down
4 changes: 2 additions & 2 deletions training/wordlist2dawg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
int main(int argc, char** argv) {
tesseract::CheckSharedLibraryVersion();

if (argc > 1 && !strcmp(argv[1], "--version")) {
if (argc > 1 && (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version"))) {
printf("%s\n", tesseract::TessBaseAPI::Version());
return 0;
} else if (!(argc == 4 || (argc == 5 && strcmp(argv[1], "-t") == 0) ||
(argc == 6 && strcmp(argv[1], "-r") == 0))) {
printf("Usage: %s --version |\n"
printf("Usage: %s -v | --version |\n"
" %s [-t | -r [reverse policy] ] word_list_file"
" dawg_file unicharset_file\n", argv[0], argv[0]);
return 1;
Expand Down

0 comments on commit 4f56abb

Please sign in to comment.