Be able to remove several books in a single command.

Fix #236
This commit is contained in:
Matthieu Gautier 2018-11-12 14:00:45 +01:00
parent cbe8f1df87
commit 1032a46c57

View File

@ -165,19 +165,22 @@ bool handle_remove(kiwix::Library* library, const std::string& libraryPath,
const unsigned int totalBookCount = library->getBookCount(true, true); const unsigned int totalBookCount = library->getBookCount(true, true);
bool exitCode = 0; bool exitCode = 0;
if (argc > 3) { if (argc <= 3) {
bookId = argv[3]; std::cerr << "BookId to remove missing in the command line" << std::endl;
return (-1);
} }
if (!library->removeBookById(bookId)) { if (!totalBookCount) {
if (totalBookCount > 0) { std::cerr << "Library is empty, no book to delete."
std::cerr << std::endl;
<< "Invalid book id." << std::endl; return 1;
exitCode = 1; }
} else {
std::cerr for (int i = 3; i<argc; i++) {
<< "Invalid book id. Library is empty, no book to delete." bookId = argv[i];
<< std::endl;
if (!library->removeBookById(bookId)) {
std::cerr << "Invalid book id '" << bookId << "'." << std::endl;
exitCode = 1; exitCode = 1;
} }
} }