2019-04-10 14:30:30 +02:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
2021-06-20 22:44:44 +02:00
|
|
|
* Copyright (C) 2019 Tom Zander <tom@flowee.org>
|
2019-04-10 14:30:30 +02:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
* (at your option) 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "IndexerClient.h"
|
2019-05-07 20:53:22 +02:00
|
|
|
#include <FloweeServiceApplication.h>
|
2019-04-10 14:30:30 +02:00
|
|
|
|
2019-11-12 15:35:54 +01:00
|
|
|
#include <utilstrencodings.h> // for SplitHostPort
|
2019-04-10 14:30:30 +02:00
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
|
{
|
|
|
|
|
FloweeServiceApplication app(argc, argv);
|
|
|
|
|
app.setOrganizationName("flowee");
|
|
|
|
|
app.setOrganizationDomain("flowee.org");
|
2019-04-10 15:38:37 +02:00
|
|
|
app.setApplicationName("indexer-cli");
|
2019-04-10 14:30:30 +02:00
|
|
|
|
|
|
|
|
QCommandLineParser parser;
|
|
|
|
|
parser.setApplicationDescription("Indexing client");
|
|
|
|
|
parser.addHelpOption();
|
2019-06-06 20:15:01 +02:00
|
|
|
parser.addPositionalArgument("[TXID|ADDRESS]", "The things you want to lookup");
|
2019-04-10 14:30:30 +02:00
|
|
|
|
|
|
|
|
QCommandLineOption hub(QStringList() << "hub", "Hub server address", "HOSTNAME");
|
|
|
|
|
parser.addOption(hub);
|
2019-04-10 17:55:08 +02:00
|
|
|
app.addClientOptions(parser);
|
2019-04-10 14:30:30 +02:00
|
|
|
parser.process(app.arguments());
|
2019-04-13 16:23:02 +02:00
|
|
|
app.setup();
|
|
|
|
|
|
2019-04-10 14:30:30 +02:00
|
|
|
auto args = parser.positionalArguments();
|
|
|
|
|
if (args.isEmpty())
|
|
|
|
|
parser.showHelp(1);
|
|
|
|
|
|
|
|
|
|
IndexerClient client;
|
|
|
|
|
if (parser.isSet(hub)) {
|
|
|
|
|
EndPoint ep;
|
2019-06-02 20:16:49 +02:00
|
|
|
uint16_t port = 1235;
|
2019-04-10 14:30:30 +02:00
|
|
|
SplitHostPort(parser.value(hub).toStdString(), port, ep.hostname);
|
|
|
|
|
ep.announcePort = port;
|
|
|
|
|
client.tryConnectHub(ep);
|
|
|
|
|
}
|
2019-06-06 17:31:23 +02:00
|
|
|
client.tryConnectIndexer(app.serverAddressFromArguments(1234));
|
2020-12-25 23:51:06 +01:00
|
|
|
for (auto &a : args) {
|
2019-06-06 17:31:23 +02:00
|
|
|
client.resolve(a);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-10 14:30:30 +02:00
|
|
|
return app.exec();
|
|
|
|
|
}
|