Add a -n (--notes) option to keepassxc-cli add and edit commands

This commit is contained in:
david authored and Jonathan White committed 2020-09-21 16:04:32 -04:00
1 parent 8a4a804c8c
commit 55eb855267
5 files changed
+47 -1

No files matched your search

+10
View File
@@ -36,6 +36,11 @@ const QCommandLineOption Add::UsernameOption = QCommandLineOption(QStringList()
const QCommandLineOption Add::UrlOption =
QCommandLineOption(QStringList() << "url", QObject::tr("URL for the entry."), QObject::tr("URL"));
const QCommandLineOption Add::NotesOption = QCommandLineOption(QStringList() << "n"
<< "notes",
QObject::tr("Notes for the entry."),
QObject::tr("Notes"));
const QCommandLineOption Add::PasswordPromptOption =
QCommandLineOption(QStringList() << "p"
<< "password-prompt",
@@ -51,6 +56,7 @@ Add::Add()
description = QObject::tr("Add a new entry to a database.");
options.append(Add::UsernameOption);
options.append(Add::UrlOption);
options.append(Add::NotesOption);
options.append(Add::PasswordPromptOption);
positionalArguments.append({QString("entry"), QObject::tr("Path of the entry to add."), QString("")});
@@ -105,6 +111,10 @@ int Add::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<Q
entry->setUrl(parser->value(Add::UrlOption));
}
if (!parser->value(Add::NotesOption).isEmpty()) {
entry->setNotes(parser->value(Add::NotesOption).replace("\\n", "\n"));
}
if (parser->isSet(Add::PasswordPromptOption)) {
if (!parser->isSet(Command::QuietOption)) {
out << QObject::tr("Enter password for new entry: ") << flush;