UsenetSearch/src/usenetindexd.cpp

57 lines
1.7 KiB
C++

/*
Copyright© 2021 John Sennesael
UsenetSearch 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
(at your option) any later version.
UsenetSearch 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 UsenetSearch. If not, see <https://www.gnu.org/licenses/>.
*/
#include "usenetsearch/Application.h"
#include "usenetsearch/Except.h"
#include "usenetsearch/Indexer.h"
#include "usenetsearch/UsenetClient.h"
#include <iostream>
using namespace usenetsearch;
int main(int argc, char* argv[])
{
Application app;
if (!app.Init(argc, argv)) return 1;
UsenetClient client(app);
Indexer indexer(app, client);
std::cout << "Connecting to newsgroup server...";
indexer.Connect();
std::cout << "<OK>" << std::endl;
try
{
std::cout << "Getting newsgroup list...";
std::cout.flush();
auto list = client.List();
app.GetDb().UpdateNewsgroupList(*list);
std::cout << "<DONE>" << std::endl;
std::cout.flush();
std::cout << "Found " << list->size() << " newsgroups." << std::endl;
std::cout.flush();
indexer.Index(*list);
}
catch (const UsenetSearchException& e)
{
std::cerr << e.what() << std::endl;;
return 1;
}
return 0;
}