pull/9/head
kelson42 15 years ago
parent d05b941255
commit 2ff5f680c8

@ -25,7 +25,7 @@
enum supportedBackend { XAPIAN, CLUCENE }; enum supportedBackend { XAPIAN, CLUCENE };
void usage() { void usage() {
cout << "Usage: kiwix-search [--verbose|-v] [--backend|-b=xapian|clucene] INDEX_PATH" << endl; cout << "Usage: kiwix-search [--verbose|-v] [--backend|-b=xapian|clucene] INDEX_PATH SEARCH" << endl;
exit(1); exit(1);
} }
@ -33,6 +33,7 @@ int main(int argc, char **argv) {
/* Init the variables */ /* Init the variables */
char *indexPath = NULL; char *indexPath = NULL;
char *search = NULL;
bool verboseFlag = false; bool verboseFlag = false;
int option_index = 0; int option_index = 0;
int c = 0; int c = 0;
@ -70,6 +71,8 @@ int main(int argc, char **argv) {
if (optind < argc) { if (optind < argc) {
if (indexPath == NULL) { if (indexPath == NULL) {
indexPath = argv[optind++]; indexPath = argv[optind++];
} else if (search == NULL) {
search = argv[optind++];
} else { } else {
cout << indexPath << endl; cout << indexPath << endl;
usage(); usage();
@ -81,7 +84,7 @@ int main(int argc, char **argv) {
} }
/* Check if we have enough arguments */ /* Check if we have enough arguments */
if (indexPath == NULL) { if (indexPath == NULL || search == NULL) {
usage(); usage();
} }
@ -99,7 +102,14 @@ int main(int argc, char **argv) {
/* Start the indexing */ /* Start the indexing */
if (searcher != NULL) { if (searcher != NULL) {
// while (searcher->indexNextPercent(verboseFlag)) {}; string searchString(search);
searcher->search(searchString, 0, 10);
string url;
string title;
unsigned int score;
while (searcher->getNextResult(url, title, score)) {
cout << title << endl;
}
} else { } else {
cerr << "Unable instanciate the Kiwix searcher." << endl; cerr << "Unable instanciate the Kiwix searcher." << endl;
exit(1); exit(1);

Loading…
Cancel
Save