From c5b293c6f3a5f54dead8e3037f8f7170bda73bea Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 2 Apr 2019 14:43:49 +0200 Subject: [PATCH] [manage] Do not show all books if id has been provided on command line. Fix #240. --- Changelog | 7 ++++++- src/manager/kiwix-manage.cpp | 29 +++++++++++++++++++---------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Changelog b/Changelog index 13321dd..208c8f8 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,4 @@ -kiwix-tools 1.2.0 +kiwix-tools 1.1.1 ================= kiwix-serve @@ -6,6 +6,11 @@ kiwix-serve * New Dockerfile of kiwix-serve +kiwix-manage +------------ + + * Do not show all books if book ids has been provided. + kiwix-tools 1.1.0 ================= diff --git a/src/manager/kiwix-manage.cpp b/src/manager/kiwix-manage.cpp index 91fe753..a4e9e96 100644 --- a/src/manager/kiwix-manage.cpp +++ b/src/manager/kiwix-manage.cpp @@ -35,14 +35,11 @@ using namespace std; enum supportedAction { NONE, ADD, SHOW, REMOVE, DOWNLOAD }; -void show(kiwix::Library* library) +void show(kiwix::Library* library, const std::string& bookId) { - auto booksIds = library->getBooksIds(); - unsigned int inc = 1; - for(auto& id: booksIds) { - auto& book = library->getBookById(id); - std::cout << "#" << inc++ << std::endl - << "id:\t\t" << book.getId() << std::endl + try { + auto& book = library->getBookById(bookId); + std::cout << "id:\t\t" << book.getId() << std::endl << "path:\t\t" << book.getPath() << std::endl << "url:\t\t" << book.getUrl() << std::endl << "title:\t\t" << book.getTitle() << std::endl @@ -53,9 +50,11 @@ void show(kiwix::Library* library) << "date:\t\t" << book.getDate() << std::endl << "articleCount:\t" << book.getArticleCount() << std::endl << "mediaCount:\t" << book.getMediaCount() << std::endl - << "size:\t\t" << book.getSize() << " KB" << std::endl - << std::endl; + << "size:\t\t" << book.getSize() << " KB" << std::endl; + } catch (std::out_of_range&) { + std::cout << "No book " << bookId << " in the library" << std::endl; } + std::cout << std::endl; } void usage() @@ -75,7 +74,17 @@ void usage() bool handle_show(kiwix::Library* library, const std::string& libraryPath, int argc, char* argv[]) { - show(library); + if (argc > 3 ) { + for(auto i=3; igetBooksIds(); + for(auto& bookId: booksIds) { + show(library, bookId); + } + } return(0); }