mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-20 18:39:16 -04:00
[manage] Do not show all books if id has been provided on command line.
Fix #240.
This commit is contained in:
parent
d57a37cde6
commit
c5b293c6f3
@ -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
|
||||
=================
|
||||
|
||||
|
@ -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; i<argc; i++) {
|
||||
std::string bookId = argv[i];
|
||||
show(library, bookId);
|
||||
}
|
||||
} else {
|
||||
auto booksIds = library->getBooksIds();
|
||||
for(auto& bookId: booksIds) {
|
||||
show(library, bookId);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user