Feature : --key-file option for CLI (#816)

* removing readFromLine

* Removing gui-prompt

* execute uses an arg list.

* Testing with key-file

* Fixing the -a option in EntropyMeter.
This commit is contained in:
louib 2017-07-25 13:41:52 -04:00 committed by GitHub
parent 1edabc4b3c
commit 1d30283514
23 changed files with 92 additions and 189 deletions

View file

@ -21,8 +21,6 @@
#include "Show.h"
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QStringList>
#include <QTextStream>
#include "core/Database.h"
@ -39,20 +37,18 @@ Show::~Show()
{
}
int Show::execute(int argc, char** argv)
int Show::execute(QStringList arguments)
{
QStringList arguments;
// Skipping the first argument (keepassxc).
for (int i = 1; i < argc; ++i) {
arguments << QString(argv[i]);
}
QCoreApplication app(argc, argv);
QTextStream out(stdout);
QCommandLineParser parser;
parser.setApplicationDescription(this->description);
parser.addPositionalArgument("database", QObject::tr("Path of the database."));
QCommandLineOption keyFile(QStringList() << "k"
<< "key-file",
QObject::tr("Key file of the database."),
QObject::tr("path"));
parser.addOption(keyFile);
parser.addPositionalArgument("entry", QObject::tr("Name of the entry to show."));
parser.process(arguments);
@ -62,7 +58,7 @@ int Show::execute(int argc, char** argv)
return EXIT_FAILURE;
}
Database* db = Database::unlockFromStdin(args.at(0));
Database* db = Database::unlockFromStdin(args.at(0), parser.value(keyFile));
if (db == nullptr) {
return EXIT_FAILURE;
}