mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-12-03 23:32:33 -08:00
Add a -n (--notes) option to keepassxc-cli add and edit commands
This commit is contained in:
1 parent
8a4a804c8c
commit
55eb855267
5 files changed
+47
-1
No files matched your search
+7
-1
@@ -41,6 +41,7 @@ Edit::Edit()
|
||||
// Using some of the options from the Add command since they are the same.
|
||||
options.append(Add::UsernameOption);
|
||||
options.append(Add::UrlOption);
|
||||
options.append(Add::NotesOption);
|
||||
options.append(Add::PasswordPromptOption);
|
||||
options.append(Edit::TitleOption);
|
||||
positionalArguments.append({QString("entry"), QObject::tr("Path of the entry to edit."), QString("")});
|
||||
@@ -91,9 +92,10 @@ int Edit::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<
|
||||
|
||||
QString username = parser->value(Add::UsernameOption);
|
||||
QString url = parser->value(Add::UrlOption);
|
||||
QString notes = parser->value(Add::NotesOption);
|
||||
QString title = parser->value(Edit::TitleOption);
|
||||
bool prompt = parser->isSet(Add::PasswordPromptOption);
|
||||
if (username.isEmpty() && url.isEmpty() && title.isEmpty() && !prompt && !generate) {
|
||||
if (username.isEmpty() && url.isEmpty() && notes.isEmpty() && title.isEmpty() && !prompt && !generate) {
|
||||
err << QObject::tr("Not changing any field for entry %1.").arg(entryPath) << endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -108,6 +110,10 @@ int Edit::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<
|
||||
entry->setUsername(username);
|
||||
}
|
||||
|
||||
if (!notes.isEmpty()) {
|
||||
entry->setNotes(notes.replace("\\n", "\n"));
|
||||
}
|
||||
|
||||
if (!url.isEmpty()) {
|
||||
entry->setUrl(url);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user