diff --git a/Changelog b/Changelog index 53ec3a3..c560df5 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,8 @@ +kiwix-tools 3.0.2 +================= + + * New option --version for all tools + kiwix-tools 3.0.1 ================= diff --git a/README.md b/README.md index 25af853..268ff35 100644 --- a/README.md +++ b/README.md @@ -161,4 +161,4 @@ License ------- [GPLv3](https://www.gnu.org/licenses/gpl-3.0) or later, see -[LICENSE](LICENSE) for more details. +[COPYING](COPYING) for more details. diff --git a/meson.build b/meson.build index e280094..0d2fe43 100644 --- a/meson.build +++ b/meson.build @@ -1,10 +1,12 @@ project('kiwix-tools', 'cpp', - version : '3.0.1', + version : '3.0.2', license : 'GPL', default_options: ['c_std=c11', 'cpp_std=c++11', 'werror=true']) compiler = meson.get_compiler('cpp') +add_global_arguments('-DKIWIX_TOOLS_VERSION="@0@"'.format(meson.project_version()), language : 'cpp') + static_linkage = get_option('static-linkage') if static_linkage add_global_link_arguments('-static-libstdc++', '--static', language:'cpp') @@ -24,5 +26,4 @@ if static_linkage endif endif -#subdir('include') subdir('src') diff --git a/src/manager/kiwix-manage.cpp b/src/manager/kiwix-manage.cpp index e676151..5b0334b 100644 --- a/src/manager/kiwix-manage.cpp +++ b/src/manager/kiwix-manage.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2011 Emmanuel Engelhart + * Copyright 2011-2019 Emmanuel Engelhart * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,8 @@ #include #include +#include "../version.h" + using namespace std; enum supportedAction { NONE, ADD, SHOW, REMOVE }; @@ -78,6 +80,9 @@ void usage() << "\t\t\t--zimPathToSave=CUSTOM_ZIM_PATH to replace the current ZIM file path" << std::endl << "\t\t\t--url=HTTP_ZIM_URL to create an \"url\" attribute for the online version of the ZIM file" << std::endl << std::endl + << "\t\t\tOther options:" << std::endl + << "\t\t\t-v, --version to print the software version" << std::endl + << std::endl << "Examples:" << std::endl << "\tAdd ZIM files to library: kiwix-manage my_library.xml add first.zim second.zim" << std::endl @@ -144,11 +149,9 @@ int handle_add(kiwix::Library* library, const std::string& libraryPath, case 'u': url = optarg; break; - case 'o': origID = optarg; break; - case 'z': zimPathToSave = optarg; break; @@ -217,7 +220,27 @@ int main(int argc, char** argv) supportedAction action = NONE; kiwix::Library library; - /* Argument parsing */ + /* General argument parsing */ + static struct option long_options[] = { + {"version", no_argument, 0, 'v'}, + {0, 0, 0, 0} + }; + + int option_index = 0; + int c; + while (true) { + c = getopt_long(argc, argv, "v", long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 'v': + version(); + return 0; + } + } + + /* Action related argument parsing */ if (argc > 2) { libraryPath = argv[1]; string actionString = argv[2]; diff --git a/src/reader/kiwix-read.cpp b/src/reader/kiwix-read.cpp index af814f8..22822f5 100644 --- a/src/reader/kiwix-read.cpp +++ b/src/reader/kiwix-read.cpp @@ -22,9 +22,11 @@ #include #include +#include "../version.h" + void usage() { - cout << "Usage: kiwix-read --suggest= ZIM_FILE_PATH" << endl; + cout << "Usage: kiwix-read [--verbose] [--version] --suggest= ZIM_FILE_PATH" << endl; exit(1); } @@ -42,15 +44,19 @@ int main(int argc, char** argv) while (42) { static struct option long_options[] = {{"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, {"suggest", required_argument, 0, 's'}, {0, 0, 0, 0}}; if (c != -1) { - c = getopt_long(argc, argv, "vs:", long_options, &option_index); + c = getopt_long(argc, argv, "Vvs:", long_options, &option_index); switch (c) { case 'v': break; + case 'V': + version(); + return 0; case 's': pattern = optarg; break; diff --git a/src/searcher/kiwix-search.cpp b/src/searcher/kiwix-search.cpp index 6f13136..99cc932 100644 --- a/src/searcher/kiwix-search.cpp +++ b/src/searcher/kiwix-search.cpp @@ -21,6 +21,7 @@ #include #include +#include "../version.h" void usage() { @@ -29,7 +30,8 @@ void usage() << " ZIM is the full path of the ZIM file." << endl << " PATTERN is/are word(s) - or part of - to search in the ZIM." << endl << endl << " -s, --suggestion\tSuggest article titles based on the few letters of the PATTERN instead of making a fulltext search. Work a bit like a completion solution." << endl - << " -v, --verbose\t\tGive details about the search process" << endl; + << " -v, --verbose\t\tGive details about the search process" << endl + << " -V, --version\t\tPrint software version" << endl; exit(1); } @@ -54,15 +56,19 @@ int main(int argc, char** argv) static struct option long_options[] = {{"verbose", no_argument, 0, 'v'}, {"suggestion", no_argument, 0, 's'}, + {"version", no_argument, 0, 'V'}, {0, 0, 0, 0}}; if (c != -1) { - c = getopt_long(argc, argv, "vsb:", long_options, &option_index); + c = getopt_long(argc, argv, "Vvsb:", long_options, &option_index); switch (c) { case 'v': verboseFlag = true; break; + case 'V': + version(); + return 0; case 's': suggestionFlag = true; break; diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index 267ad49..86c650e 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2009-2016 Emmanuel Engelhart + * Copyright 2009-2019 Emmanuel Engelhart * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,6 +33,8 @@ # define MIBSIZE 4 #endif +#include "../version.h" + #define DEFAULT_THREADS 4 void usage() @@ -62,6 +64,7 @@ void usage() << "\t-r, --urlRootLocation\tURL prefix on which the content should be made available (default: /)" << std::endl << "\t-t, --threads\t\tnumber of threads to run in parallel (default: " << DEFAULT_THREADS << ")" << std::endl << "\t-v, --verbose\t\tprint debug log to STDOUT" << std::endl + << "\t-V, --version\t\tprint software version" << std::endl << "\t-z, --nodatealiases\tcreate URL aliases for each content by removing the date" << std::endl << std::endl @@ -93,6 +96,7 @@ int main(int argc, char** argv) static struct option long_options[] = {{"daemon", no_argument, 0, 'd'}, {"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, {"library", no_argument, 0, 'l'}, {"nolibrarybutton", no_argument, 0, 'm'}, {"nodatealiases", no_argument, 0, 'z'}, @@ -108,7 +112,7 @@ int main(int argc, char** argv) while (true) { int option_index = 0; int c - = getopt_long(argc, argv, "mndvla:p:f:t:r:", long_options, &option_index); + = getopt_long(argc, argv, "mndvVla:p:f:t:r:", long_options, &option_index); if (c != -1) { switch (c) { @@ -118,6 +122,9 @@ int main(int argc, char** argv) case 'v': isVerboseFlag = true; break; + case 'V': + version(); + return 0; case 'l': libraryFlag = true; break; diff --git a/src/version.h b/src/version.h new file mode 100644 index 0000000..0b556cf --- /dev/null +++ b/src/version.h @@ -0,0 +1,32 @@ +/* + * Copyright 2009-2016 Emmanuel Engelhart + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#ifndef _KIWIX_TOOLS_VERSION_H_ +#define _KIWIX_TOOLS_VERSION_H_ + +#ifndef KIWIX_TOOLS_VERSION + #define KIWIX_TOOLS_VERSION "undefined" +#endif + +void version() +{ + std::cout << KIWIX_TOOLS_VERSION << std::endl; +} + +#endif //_KIWIX_TOOLs_VERSION_H_