From d68ab9f12e9d25f02660255fb4d4052e588cd7fb Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 20 Apr 2018 22:15:04 +0200 Subject: [PATCH] training: Support new command line option -v (short form for --version) Signed-off-by: Stefan Weil --- training/ambiguous_words.cpp | 4 ++-- training/combine_tessdata.cpp | 2 +- training/commandlineflags.cpp | 4 +++- training/commontraining.cpp | 2 +- training/dawg2wordlist.cpp | 4 ++-- training/merge_unicharsets.cpp | 4 ++-- training/wordlist2dawg.cpp | 4 ++-- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/training/ambiguous_words.cpp b/training/ambiguous_words.cpp index 80bc3747d4..9cf792466e 100644 --- a/training/ambiguous_words.cpp +++ b/training/ambiguous_words.cpp @@ -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; } diff --git a/training/combine_tessdata.cpp b/training/combine_tessdata.cpp index b0ae1bff6b..3eb8d8541b 100644 --- a/training/combine_tessdata.cpp +++ b/training/combine_tessdata.cpp @@ -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) { diff --git a/training/commandlineflags.cpp b/training/commandlineflags.cpp index 9c61386dff..b857232169 100644 --- a/training/commandlineflags.cpp +++ b/training/commandlineflags.cpp @@ -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); } diff --git a/training/commontraining.cpp b/training/commontraining.cpp index 19056515f8..c961c3a466 100644 --- a/training/commontraining.cpp +++ b/training/commontraining.cpp @@ -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 ...]"; diff --git a/training/dawg2wordlist.cpp b/training/dawg2wordlist.cpp index 36b036ba2c..355c6fba81 100644 --- a/training/dawg2wordlist.cpp +++ b/training/dawg2wordlist.cpp @@ -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 \n", + tprintf("Usage: %s -v | --version | %s \n", argv[0], argv[0]); return 1; } diff --git a/training/merge_unicharsets.cpp b/training/merge_unicharsets.cpp index 814ac85909..f5facbda48 100644 --- a/training/merge_unicharsets.cpp +++ b/training/merge_unicharsets.cpp @@ -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; diff --git a/training/wordlist2dawg.cpp b/training/wordlist2dawg.cpp index 157d03b9de..dd6b730669 100644 --- a/training/wordlist2dawg.cpp +++ b/training/wordlist2dawg.cpp @@ -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;