mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-07 06:27:39 +03:00
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:
parent
1edabc4b3c
commit
1d30283514
23 changed files with 92 additions and 189 deletions
|
@ -22,16 +22,13 @@
|
|||
|
||||
#include "Clip.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QStringList>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "cli/Utils.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Entry.h"
|
||||
#include "core/Group.h"
|
||||
#include "gui/UnlockDatabaseDialog.h"
|
||||
|
||||
Clip::Clip()
|
||||
{
|
||||
|
@ -43,24 +40,19 @@ Clip::~Clip()
|
|||
{
|
||||
}
|
||||
|
||||
int Clip::execute(int argc, char** argv)
|
||||
int Clip::execute(QStringList arguments)
|
||||
{
|
||||
QStringList arguments;
|
||||
// Skipping the first argument (keepassxc).
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
arguments << QString(argv[i]);
|
||||
}
|
||||
|
||||
QTextStream out(stdout);
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription(this->description);
|
||||
parser.addPositionalArgument("database", QObject::tr("Path of the database."));
|
||||
QCommandLineOption guiPrompt(QStringList() << "g"
|
||||
<< "gui-prompt",
|
||||
QObject::tr("Use a GUI prompt unlocking the database."));
|
||||
parser.addOption(guiPrompt);
|
||||
QCommandLineOption keyFile(QStringList() << "k"
|
||||
<< "key-file",
|
||||
QObject::tr("Key file of the database."),
|
||||
QObject::tr("path"));
|
||||
parser.addOption(keyFile);
|
||||
parser.addPositionalArgument("entry", QObject::tr("Path of the entry to clip."));
|
||||
parser.addPositionalArgument(
|
||||
"timeout",
|
||||
|
@ -74,16 +66,11 @@ int Clip::execute(int argc, char** argv)
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
Database* db = nullptr;
|
||||
if (parser.isSet("gui-prompt")) {
|
||||
db = UnlockDatabaseDialog::openDatabasePrompt(args.at(0));
|
||||
} else {
|
||||
db = Database::unlockFromStdin(args.at(0));
|
||||
}
|
||||
|
||||
Database* db = Database::unlockFromStdin(args.at(0), parser.value(keyFile));
|
||||
if (!db) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return this->clipEntry(db, args.at(1), args.value(2));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue