Files
thehub/unspentdb/main.cpp
T

84 lines
3.2 KiB
C++
Raw Permalink Normal View History

/*
* This file is part of the Flowee project
* Copyright (C) 2018 Tom Zander <tomz@freedommail.ch>
*
* 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 "AbstractCommand.h"
#include "CheckCommand.h"
2018-09-09 14:52:45 +02:00
#include "ExportCommand.h"
#include "InfoCommand.h"
2018-09-09 22:08:28 +02:00
#include "LookupCommand.h"
2018-09-08 11:40:29 +02:00
#include "PruneCommand.h"
2020-03-05 22:25:01 +01:00
#include "DuplicateCommand.h"
2018-09-05 22:52:45 +02:00
#include <QCoreApplication>
#include <QTextStream>
#include <QStandardPaths>
2018-09-05 22:52:45 +02:00
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
app.setOrganizationName("flowee");
app.setOrganizationDomain("flowee.org");
app.setApplicationName("unspentdb");
2018-09-05 22:52:45 +02:00
QStringList args = app.arguments();
if (argc > 2 && args.at(1) == QLatin1String("help")) { // 'help foo' -> 'foo -h'
args[1] = args[2];
args[2] = QLatin1String("--help");
}
AbstractCommand *run = nullptr;
if (args.size() > 1) {
const QString command = args.at(1);
if (command == "info")
run = new InfoCommand();
2018-09-08 11:40:29 +02:00
else if (command == "prune")
run = new PruneCommand();
else if (command == "check")
run = new CheckCommand();
2018-09-09 14:52:45 +02:00
else if (command == "export")
run = new ExportCommand();
2018-09-09 22:08:28 +02:00
else if (command == "lookup")
run = new LookupCommand();
2020-03-05 22:25:01 +01:00
else if (command == "duplicate")
run = new DuplicateCommand();
}
if (run == nullptr) {
QTextStream out(stdout);
out << "Usage unspentdb COMMAND [OPTIONS] ...\n" << endl;
out << "Options:" << endl;
out << "-f, --datafile <PATH> <PATH> to datafile.db." << endl;
out << "-d, --unspent <PATH> <PATH> to unspent datadir." << endl;
out << "-i, --info <PATH> <PATH> to specific info file." << endl << endl;
out << "Commands:" << endl;
out << " help Display help for unspentdb or single commands." << endl;
2018-09-09 22:08:28 +02:00
out << "Querying the database:" << endl;
out << " lookup Finds utxo entries." << endl;
out << " info Prints generic info about a database or part of it." << endl;
2018-09-09 14:52:45 +02:00
out << " export Exports the entire set of a database." << endl;
2018-09-09 22:08:28 +02:00
out << "Database maintainance:" << endl;
out << " check Checks the internal structures of the database." << endl;
2018-09-08 11:40:29 +02:00
out << " prune Prunes spent outputs to speed up database usage." << endl;
2020-03-05 22:25:01 +01:00
out << "Other:" << endl;
out << " duplicate Duplicates a file or a directory of the database." << endl;
out << endl;
return Flowee::InvalidOptions;
}
args.takeAt(1); // remove the command
return run->start(args);
2018-09-05 22:52:45 +02:00
}