mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-27 00:09:53 -05:00
Merge pull request #54 from jkt628/develop
add command line option --pw-stdin to accept password from stdin
This commit is contained in:
commit
cf2bbbfef1
11
src/main.cpp
11
src/main.cpp
@ -17,6 +17,7 @@
|
||||
|
||||
#include <QCommandLineParser>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "config-keepassx.h"
|
||||
#include "core/Config.h"
|
||||
@ -61,11 +62,14 @@ int main(int argc, char** argv)
|
||||
QCommandLineOption keyfileOption("keyfile",
|
||||
QCoreApplication::translate("main", "key file of the database"),
|
||||
"keyfile");
|
||||
QCommandLineOption pwstdinOption("pw-stdin",
|
||||
QCoreApplication::translate("main", "read password of the database from stdin"));
|
||||
|
||||
parser.addHelpOption();
|
||||
parser.addVersionOption();
|
||||
parser.addOption(configOption);
|
||||
parser.addOption(keyfileOption);
|
||||
parser.addOption(pwstdinOption);
|
||||
|
||||
parser.process(app);
|
||||
const QStringList args = parser.positionalArguments();
|
||||
@ -90,7 +94,12 @@ int main(int argc, char** argv)
|
||||
for (int ii=0; ii < args.length(); ii++) {
|
||||
QString filename = args[ii];
|
||||
if (!filename.isEmpty() && QFile::exists(filename)) {
|
||||
mainWindow.openDatabase(filename, QString(), parser.value(keyfileOption));
|
||||
QString password;
|
||||
if (parser.isSet(pwstdinOption)) {
|
||||
static QTextStream in(stdin, QIODevice::ReadOnly);
|
||||
password = in.readLine();
|
||||
}
|
||||
mainWindow.openDatabase(filename, password, parser.value(keyfileOption));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user