mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-26 13:50:33 -04:00
+ fixed buggy kiwix-manage remove feature
This commit is contained in:
parent
d84c8e7924
commit
5c9ec9cf3b
@ -174,15 +174,20 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
} else if (action == REMOVE) {
|
} else if (action == REMOVE) {
|
||||||
unsigned int bookIndex = 0;
|
unsigned int bookIndex = 0;
|
||||||
|
const unsigned int totalBookCount = libraryManager.getBookCount(true, true);
|
||||||
|
|
||||||
if (argc>3) {
|
if (argc>3) {
|
||||||
bookIndex = atoi(argv[3]);
|
bookIndex = atoi(argv[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bookIndex > 0) {
|
if (bookIndex > 0 && bookIndex <= totalBookCount) {
|
||||||
libraryManager.removeBookByIndex(bookIndex);
|
libraryManager.removeBookByIndex(bookIndex - 1);
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Invalid book index number" << std::endl;
|
if (totalBookCount > 0) {
|
||||||
|
std::cerr << "Invalid book index number. Please give a number between 1 and " << totalBookCount << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cerr << "Invalid book index number. Library is empty, no book to delete." << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user