mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-27 06:47:02 -05:00
Global const for KeyFileOption (CLI) (#2505)
This commit is contained in:
parent
1a2721529d
commit
49b82ea6a2
@ -49,11 +49,7 @@ int Add::execute(const QStringList& arguments)
|
||||
parser.setApplicationDescription(description);
|
||||
parser.addPositionalArgument("database", QObject::tr("Path of the database."));
|
||||
parser.addOption(Command::QuietOption);
|
||||
|
||||
QCommandLineOption keyFile(QStringList() << "k" << "key-file",
|
||||
QObject::tr("Key file of the database."),
|
||||
QObject::tr("path"));
|
||||
parser.addOption(keyFile);
|
||||
parser.addOption(Command::KeyFileOption);
|
||||
|
||||
QCommandLineOption username(QStringList() << "u" << "username",
|
||||
QObject::tr("Username for the entry."),
|
||||
@ -91,7 +87,7 @@ int Add::execute(const QStringList& arguments)
|
||||
const QString& entryPath = args.at(1);
|
||||
|
||||
auto db = Database::unlockFromStdin(databasePath,
|
||||
parser.value(keyFile),
|
||||
parser.value(Command::KeyFileOption),
|
||||
parser.isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
||||
Utils::STDERR);
|
||||
if (!db) {
|
||||
|
@ -47,11 +47,9 @@ int Clip::execute(const QStringList& arguments)
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription(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.addOption(Command::QuietOption);
|
||||
parser.addOption(Command::KeyFileOption);
|
||||
|
||||
QCommandLineOption totp(QStringList() << "t" << "totp",
|
||||
QObject::tr("Copy the current TOTP to the clipboard."));
|
||||
parser.addOption(totp);
|
||||
@ -68,7 +66,7 @@ int Clip::execute(const QStringList& arguments)
|
||||
}
|
||||
|
||||
auto db = Database::unlockFromStdin(args.at(0),
|
||||
parser.value(keyFile),
|
||||
parser.value(Command::KeyFileOption),
|
||||
parser.isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
||||
Utils::STDERR);
|
||||
if (!db) {
|
||||
|
@ -39,6 +39,13 @@ const QCommandLineOption Command::QuietOption =
|
||||
QCommandLineOption(QStringList() << "q"
|
||||
<< "quiet",
|
||||
QObject::tr("Silence password prompt and other secondary outputs."));
|
||||
|
||||
const QCommandLineOption Command::KeyFileOption =
|
||||
QCommandLineOption(QStringList() << "k"
|
||||
<< "key-file",
|
||||
QObject::tr("Key file of the database."),
|
||||
QObject::tr("path"));
|
||||
|
||||
QMap<QString, Command*> commands;
|
||||
|
||||
Command::~Command()
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
static Command* getCommand(const QString& commandName);
|
||||
|
||||
static const QCommandLineOption QuietOption;
|
||||
static const QCommandLineOption KeyFileOption;
|
||||
};
|
||||
|
||||
#endif // KEEPASSXC_COMMAND_H
|
||||
|
@ -49,11 +49,7 @@ int Edit::execute(const QStringList& arguments)
|
||||
parser.setApplicationDescription(description);
|
||||
parser.addPositionalArgument("database", QObject::tr("Path of the database."));
|
||||
parser.addOption(Command::QuietOption);
|
||||
|
||||
QCommandLineOption keyFile(QStringList() << "k" << "key-file",
|
||||
QObject::tr("Key file of the database."),
|
||||
QObject::tr("path"));
|
||||
parser.addOption(keyFile);
|
||||
parser.addOption(Command::KeyFileOption);
|
||||
|
||||
QCommandLineOption username(QStringList() << "u" << "username",
|
||||
QObject::tr("Username for the entry."),
|
||||
@ -95,7 +91,7 @@ int Edit::execute(const QStringList& arguments)
|
||||
const QString& entryPath = args.at(1);
|
||||
|
||||
auto db = Database::unlockFromStdin(databasePath,
|
||||
parser.value(keyFile),
|
||||
parser.value(Command::KeyFileOption),
|
||||
parser.isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
||||
Utils::STDERR);
|
||||
if (!db) {
|
||||
|
@ -50,10 +50,7 @@ int Extract::execute(const QStringList& arguments)
|
||||
parser.setApplicationDescription(description);
|
||||
parser.addPositionalArgument("database", QObject::tr("Path of the database to extract."));
|
||||
parser.addOption(Command::QuietOption);
|
||||
QCommandLineOption keyFile(QStringList() << "k" << "key-file",
|
||||
QObject::tr("Key file of the database."),
|
||||
QObject::tr("path"));
|
||||
parser.addOption(keyFile);
|
||||
parser.addOption(Command::KeyFileOption);
|
||||
parser.addHelpOption();
|
||||
parser.process(arguments);
|
||||
|
||||
@ -74,7 +71,7 @@ int Extract::execute(const QStringList& arguments)
|
||||
passwordKey->setPassword(line);
|
||||
compositeKey->addKey(passwordKey);
|
||||
|
||||
QString keyFilePath = parser.value(keyFile);
|
||||
QString keyFilePath = parser.value(Command::KeyFileOption);
|
||||
if (!keyFilePath.isEmpty()) {
|
||||
// LCOV_EXCL_START
|
||||
auto fileKey = QSharedPointer<FileKey>::create();
|
||||
|
@ -47,10 +47,8 @@ int List::execute(const QStringList& arguments)
|
||||
parser.addPositionalArgument("database", QObject::tr("Path of the database."));
|
||||
parser.addPositionalArgument("group", QObject::tr("Path of the group to list. Default is /"), "[group]");
|
||||
parser.addOption(Command::QuietOption);
|
||||
QCommandLineOption keyFile(QStringList() << "k" << "key-file",
|
||||
QObject::tr("Key file of the database."),
|
||||
QObject::tr("path"));
|
||||
parser.addOption(keyFile);
|
||||
parser.addOption(Command::KeyFileOption);
|
||||
|
||||
QCommandLineOption recursiveOption(QStringList() << "R" << "recursive",
|
||||
QObject::tr("Recursively list the elements of the group."));
|
||||
parser.addOption(recursiveOption);
|
||||
@ -66,7 +64,7 @@ int List::execute(const QStringList& arguments)
|
||||
bool recursive = parser.isSet(recursiveOption);
|
||||
|
||||
auto db = Database::unlockFromStdin(args.at(0),
|
||||
parser.value(keyFile),
|
||||
parser.value(Command::KeyFileOption),
|
||||
parser.isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
||||
Utils::STDERR);
|
||||
if (!db) {
|
||||
|
@ -49,10 +49,7 @@ int Locate::execute(const QStringList& arguments)
|
||||
parser.addPositionalArgument("database", QObject::tr("Path of the database."));
|
||||
parser.addPositionalArgument("term", QObject::tr("Search term."));
|
||||
parser.addOption(Command::QuietOption);
|
||||
QCommandLineOption keyFile(QStringList() << "k" << "key-file",
|
||||
QObject::tr("Key file of the database."),
|
||||
QObject::tr("path"));
|
||||
parser.addOption(keyFile);
|
||||
parser.addOption(Command::KeyFileOption);
|
||||
parser.addHelpOption();
|
||||
parser.process(arguments);
|
||||
|
||||
@ -63,7 +60,7 @@ int Locate::execute(const QStringList& arguments)
|
||||
}
|
||||
|
||||
auto db = Database::unlockFromStdin(args.at(0),
|
||||
parser.value(keyFile),
|
||||
parser.value(Command::KeyFileOption),
|
||||
parser.isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
||||
Utils::STDERR);
|
||||
if (!db) {
|
||||
|
@ -50,14 +50,12 @@ int Merge::execute(const QStringList& arguments)
|
||||
QCommandLineOption samePasswordOption(QStringList() << "s" << "same-credentials",
|
||||
QObject::tr("Use the same credentials for both database files."));
|
||||
parser.addOption(samePasswordOption);
|
||||
QCommandLineOption keyFile(QStringList() << "k" << "key-file",
|
||||
QObject::tr("Key file of the database."),
|
||||
QObject::tr("path"));
|
||||
parser.addOption(keyFile);
|
||||
QCommandLineOption keyFileFrom(QStringList() << "f" << "key-file-from",
|
||||
QObject::tr("Key file of the database to merge from."),
|
||||
QObject::tr("path"));
|
||||
parser.addOption(keyFileFrom);
|
||||
parser.addOption(Command::KeyFileOption);
|
||||
|
||||
QCommandLineOption keyFileFromOption(QStringList() << "f" << "key-file-from",
|
||||
QObject::tr("Key file of the database to merge from."),
|
||||
QObject::tr("path"));
|
||||
parser.addOption(keyFileFromOption);
|
||||
|
||||
parser.addHelpOption();
|
||||
parser.process(arguments);
|
||||
@ -69,7 +67,7 @@ int Merge::execute(const QStringList& arguments)
|
||||
}
|
||||
|
||||
auto db1 = Database::unlockFromStdin(args.at(0),
|
||||
parser.value(keyFile),
|
||||
parser.value(Command::KeyFileOption),
|
||||
parser.isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
||||
Utils::STDERR);
|
||||
if (!db1) {
|
||||
@ -78,10 +76,7 @@ int Merge::execute(const QStringList& arguments)
|
||||
|
||||
QSharedPointer<Database> db2;
|
||||
if (!parser.isSet("same-credentials")) {
|
||||
db2 = Database::unlockFromStdin(args.at(1),
|
||||
parser.value(keyFileFrom),
|
||||
parser.isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
||||
Utils::STDERR);
|
||||
db2 = Database::unlockFromStdin(args.at(1), parser.value(keyFileFromOption), Utils::STDOUT, Utils::STDERR);
|
||||
} else {
|
||||
db2 = QSharedPointer<Database>::create();
|
||||
QString errorMessage;
|
||||
|
@ -50,10 +50,7 @@ int Remove::execute(const QStringList& arguments)
|
||||
parser.setApplicationDescription(QCoreApplication::tr("main", "Remove an entry from the database."));
|
||||
parser.addPositionalArgument("database", QCoreApplication::tr("main", "Path of the database."));
|
||||
parser.addOption(Command::QuietOption);
|
||||
QCommandLineOption keyFile(QStringList() << "k" << "key-file",
|
||||
QObject::tr("Key file of the database."),
|
||||
QObject::tr("path"));
|
||||
parser.addOption(keyFile);
|
||||
parser.addOption(Command::KeyFileOption);
|
||||
parser.addPositionalArgument("entry", QCoreApplication::tr("main", "Path of the entry to remove."));
|
||||
parser.addHelpOption();
|
||||
parser.process(arguments);
|
||||
@ -65,7 +62,7 @@ int Remove::execute(const QStringList& arguments)
|
||||
}
|
||||
|
||||
auto db = Database::unlockFromStdin(args.at(0),
|
||||
parser.value(keyFile),
|
||||
parser.value(Command::KeyFileOption),
|
||||
parser.isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
||||
Utils::STDERR);
|
||||
if (!db) {
|
||||
|
@ -46,11 +46,8 @@ int Show::execute(const QStringList& arguments)
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription(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.addOption(Command::QuietOption);
|
||||
parser.addOption(Command::KeyFileOption);
|
||||
QCommandLineOption totp(QStringList() << "t" << "totp",
|
||||
QObject::tr("Show the entry's current TOTP."));
|
||||
parser.addOption(totp);
|
||||
@ -73,7 +70,7 @@ int Show::execute(const QStringList& arguments)
|
||||
}
|
||||
|
||||
auto db = Database::unlockFromStdin(args.at(0),
|
||||
parser.value(keyFile),
|
||||
parser.value(Command::KeyFileOption),
|
||||
parser.isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
|
||||
Utils::STDERR);
|
||||
if (!db) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user