Skip to content

Commit

Permalink
training: Support new command line option -v (short form for --version)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Apr 20, 2018
1 parent 5435c9c commit d68ab9f
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
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
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
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
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
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
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
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 d68ab9f

Please sign in to comment.