mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-23 03:52:35 -04:00
+ kiwix-manage new devs.
This commit is contained in:
parent
417749a3fc
commit
2b30f4239d
@ -25,6 +25,14 @@ using namespace std;
|
|||||||
|
|
||||||
enum supportedAction { NONE, ADD, SHOW, REMOVE };
|
enum supportedAction { NONE, ADD, SHOW, REMOVE };
|
||||||
|
|
||||||
|
void show(kiwix::Library library) {
|
||||||
|
std::vector<kiwix::Book>::iterator itr;
|
||||||
|
unsigned int inc = 1;
|
||||||
|
for ( itr = library.books.begin(); itr != library.books.end(); ++itr ) {
|
||||||
|
std::cout << "#" << inc++ << ": " << itr->path << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
string libraryPath = "";
|
string libraryPath = "";
|
||||||
@ -51,24 +59,28 @@ int main(int argc, char **argv) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Try to read the file */
|
||||||
|
libraryManager.readFile(libraryPath);
|
||||||
|
|
||||||
/* SHOW */
|
/* SHOW */
|
||||||
if (action == SHOW) {
|
if (action == SHOW) {
|
||||||
if (libraryManager.readFile(libraryPath)) {
|
show(libraryManager.cloneLibrary());
|
||||||
kiwix::Library library = libraryManager.cloneLibrary();
|
|
||||||
std::vector<kiwix::Book>::iterator itr;
|
|
||||||
unsigned int inc = 1;
|
|
||||||
for ( itr = library.books.begin(); itr != library.books.end(); ++itr ) {
|
|
||||||
std::cout << "#" << inc++ << ": " << itr->path << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
std::cerr << "Unable to read the library file '" << libraryPath << "'." << std::endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
} else if (action == ADD) {
|
} else if (action == ADD) {
|
||||||
std::cerr << "ADD is still not implemented." << std::endl;
|
std::cerr << "ADD is still not implemented." << std::endl;
|
||||||
} else if (action == REMOVE) {
|
} else if (action == REMOVE) {
|
||||||
std::cerr << "REMOVE is still not implemented." << std::endl;
|
unsigned int bookIndex = 0;
|
||||||
|
|
||||||
|
if (argc>3) {
|
||||||
|
bookIndex = atoi(argv[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bookIndex > 0) {
|
||||||
|
libraryManager.removeBookByIndex(bookIndex);
|
||||||
|
} else {
|
||||||
|
std::cerr << "Invalid book index number" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
libraryManager.writeFile(libraryPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user