mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2026-04-28 03:30:03 +00:00
Goodbye kiwix-read
`kiwix-read` was a confusing tool. It was a loose equivalent of `kiwix-search --suggest` also able to work on old ZIM archives that didn't contain a title index. Its existence is not justified.
This commit is contained in:
parent
2bb080ee3b
commit
f9ce353ad1
3 changed files with 0 additions and 112 deletions
|
|
@ -1,6 +1,4 @@
|
||||||
|
|
||||||
subdir('manager')
|
subdir('manager')
|
||||||
subdir('reader')
|
|
||||||
subdir('searcher')
|
subdir('searcher')
|
||||||
subdir('server')
|
subdir('server')
|
||||||
subdir('man')
|
subdir('man')
|
||||||
|
|
|
||||||
|
|
@ -1,107 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2011 Emmanuel Engelhart <kelson@kiwix.org>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
||||||
* MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <getopt.h>
|
|
||||||
#include <kiwix/reader.h>
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "../version.h"
|
|
||||||
|
|
||||||
void usage()
|
|
||||||
{
|
|
||||||
cout << "Usage: kiwix-read [--verbose] [--version] --suggest=<PATTERN> ZIM_FILE_PATH" << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
/* Init the variables */
|
|
||||||
const char* filePath = NULL;
|
|
||||||
const char* pattern = NULL;
|
|
||||||
int option_index = 0;
|
|
||||||
int c = 0;
|
|
||||||
|
|
||||||
kiwix::Reader* reader = NULL;
|
|
||||||
|
|
||||||
/* Argument parsing */
|
|
||||||
while (42) {
|
|
||||||
static struct option long_options[]
|
|
||||||
= {{"verbose", no_argument, 0, 'v'},
|
|
||||||
{"version", no_argument, 0, 'V'},
|
|
||||||
{"suggest", required_argument, 0, 's'},
|
|
||||||
{0, 0, 0, 0}};
|
|
||||||
|
|
||||||
if (c != -1) {
|
|
||||||
c = getopt_long(argc, argv, "Vvs:", long_options, &option_index);
|
|
||||||
|
|
||||||
switch (c) {
|
|
||||||
case 'v':
|
|
||||||
break;
|
|
||||||
case 'V':
|
|
||||||
version();
|
|
||||||
return 0;
|
|
||||||
case 's':
|
|
||||||
pattern = optarg;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (optind < argc) {
|
|
||||||
if (filePath == NULL) {
|
|
||||||
filePath = argv[optind++];
|
|
||||||
} else {
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if we have enough arguments */
|
|
||||||
if (filePath == NULL) {
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Instanciate the reader */
|
|
||||||
reader = new kiwix::Reader(filePath);
|
|
||||||
|
|
||||||
/* Start to read an article */
|
|
||||||
if (reader != NULL) {
|
|
||||||
string content;
|
|
||||||
string contentType;
|
|
||||||
string suggestion;
|
|
||||||
|
|
||||||
if (pattern != NULL) {
|
|
||||||
std::cout << "Searching suggestions for: " << pattern << std::endl;
|
|
||||||
kiwix::SuggestionsList_t suggestions;
|
|
||||||
reader->searchSuggestionsSmart(pattern, 10, suggestions);
|
|
||||||
for (auto& suggestion: suggestions) {
|
|
||||||
std::cout << suggestion.getTitle() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete reader;
|
|
||||||
} else {
|
|
||||||
cerr << "Unable instanciate the Kiwix reader." << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
executable('kiwix-read', ['kiwix-read.cpp'],
|
|
||||||
dependencies:all_deps,
|
|
||||||
install:true)
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue