6 #include "WikiWalker.h"
8 #include "BoostPoCommandLineParser.h"
9 #include "ToGraphvizWriter.h"
13 int main(int argc
, char** argv
)
15 BoostPoCommandLineParser cmdp
;
18 cmdp
.parse(argc
, argv
);
19 } catch(std::exception
& e
) {
20 cerr
<< endl
<< e
.what() << endl
;
25 if (cmdp
.hasSet("version")) {
26 std::cout
<< "WikiWalker, version " << _WW_VERSION
<< std::endl
;
30 if (cmdp
.hasSet("help")) {
35 bool isUrlSet
= cmdp
.hasSet("url");
36 bool isCacheSet
= cmdp
.hasSet("json-cache");
37 bool isDotSet
= cmdp
.hasSet("dot-out");
38 bool validRunConfig
= isUrlSet
|| (isDotSet
&& isCacheSet
);
41 cerr
<< "Must either specify at least URL, "
42 << "or dot and cache file." << endl
;
47 bool read_failed
= false;
52 std::string cachefile
= cmdp
.getValue("json-cache");
53 w
.readCache(cachefile
);
54 } catch(std::exception
& e
) {
55 std::cout
<< e
.what() << endl
;
62 std::string url
= cmdp
.getValue("url");
64 } catch(std::exception
& e
) {
65 cout
<< "Error " << e
.what() << endl
;
72 cout
<< "Reading from cache failed, won't overwrite" << endl
;
75 std::string cachefile
= cmdp
.getValue("json-cache");
76 w
.writeCache(cachefile
);
77 } catch(std::exception
& e
) {
78 cout
<< "Error: " << e
.what() << endl
;
84 const ArticleCollection
& ac
= w
.getCollection();
85 std::string outfile
= cmdp
.getValue("dot-out");
87 ofstream
file(outfile
, ios::trunc
| ios::out
);
90 cerr
<< "Error opening dot out file for writing" << endl
;
95 if(file
.bad() || file
.fail()) {
96 cerr
<< "Error during writing dot out file." << endl
;