From 730c5db384559dd4397d07ecaf4fa8407cff9542 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Thu, 12 Dec 2013 12:23:53 +0100 Subject: [PATCH] + able now to retrieve suggestions --- src/reader/kiwix-read.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/reader/kiwix-read.cpp b/src/reader/kiwix-read.cpp index 3832099..27304e5 100644 --- a/src/reader/kiwix-read.cpp +++ b/src/reader/kiwix-read.cpp @@ -37,7 +37,7 @@ int main(int argc, char **argv) { /* Init the variables */ const char *filePath = NULL; - const char *suggestion = NULL; + const char *pattern = NULL; int option_index = 0; int c = 0; @@ -48,15 +48,19 @@ int main(int argc, char **argv) { static struct option long_options[] = { {"verbose", no_argument, 0, 'v'}, + {"suggest", required_argument, 0, 's'}, {0, 0, 0, 0} }; if (c != -1) { - c = getopt_long(argc, argv, "v", long_options, &option_index); + c = getopt_long(argc, argv, "vs:", long_options, &option_index); switch (c) { case 'v': break; + case 's': + pattern = optarg; + break; } } else { if (optind < argc) { @@ -85,15 +89,25 @@ int main(int argc, char **argv) { string content; string contentType; unsigned int contentLength = 0; + string suggestion; + if (pattern != NULL) { + std::cout << "Searching suggestions for: " << pattern << std::endl; + + reader->searchSuggestionsSmart(pattern, 10); + while (reader->getNextSuggestion(suggestion)) { + std::cout << suggestion << std::endl; + } + } + /* if (reader->getContentByUrl(mainPageUrl, content, contentLength, contentType)) { cout << content << endl; } */ - tree< pair > tree; - updateSuggestionTree(tree, string(suggestion)); + // tree< pair > tree; + //updateSuggestionTree(tree, string(suggestion)); delete reader; } else {