Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/Edit.cpp')
-rw-r--r--src/cli/Edit.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/cli/Edit.cpp b/src/cli/Edit.cpp
index 30dccf15e..6fd1b0369 100644
--- a/src/cli/Edit.cpp
+++ b/src/cli/Edit.cpp
@@ -60,16 +60,15 @@ Edit::Edit()
int Edit::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser)
{
- TextStream outputTextStream(parser->isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
- QIODevice::WriteOnly);
- TextStream errorTextStream(Utils::STDERR, QIODevice::WriteOnly);
+ auto& out = parser->isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT;
+ auto& err = Utils::STDERR;
const QStringList args = parser->positionalArguments();
const QString& entryPath = args.at(1);
// Cannot use those 2 options at the same time!
if (parser->isSet(Add::GenerateOption) && parser->isSet(Add::PasswordPromptOption)) {
- errorTextStream << QObject::tr("Cannot generate a password and prompt at the same time!") << endl;
+ err << QObject::tr("Cannot generate a password and prompt at the same time!") << endl;
return EXIT_FAILURE;
}
@@ -86,7 +85,7 @@ int Edit::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<
Entry* entry = database->rootGroup()->findEntryByPath(entryPath);
if (!entry) {
- errorTextStream << QObject::tr("Could not find entry with path %1.").arg(entryPath) << endl;
+ err << QObject::tr("Could not find entry with path %1.").arg(entryPath) << endl;
return EXIT_FAILURE;
}
@@ -95,7 +94,7 @@ int Edit::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<
QString title = parser->value(Edit::TitleOption);
bool prompt = parser->isSet(Add::PasswordPromptOption);
if (username.isEmpty() && url.isEmpty() && title.isEmpty() && !prompt && !generate) {
- errorTextStream << QObject::tr("Not changing any field for entry %1.").arg(entryPath) << endl;
+ err << QObject::tr("Not changing any field for entry %1.").arg(entryPath) << endl;
return EXIT_FAILURE;
}
@@ -114,8 +113,8 @@ int Edit::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<
}
if (prompt) {
- outputTextStream << QObject::tr("Enter new password for entry: ") << flush;
- QString password = Utils::getPassword(parser->isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT);
+ out << QObject::tr("Enter new password for entry: ") << flush;
+ QString password = Utils::getPassword(parser->isSet(Command::QuietOption));
entry->setPassword(password);
} else if (generate) {
QString password = passwordGenerator->generatePassword();
@@ -126,10 +125,10 @@ int Edit::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<
QString errorMessage;
if (!database->save(&errorMessage, true, false)) {
- errorTextStream << QObject::tr("Writing the database failed: %1").arg(errorMessage) << endl;
+ err << QObject::tr("Writing the database failed: %1").arg(errorMessage) << endl;
return EXIT_FAILURE;
}
- outputTextStream << QObject::tr("Successfully edited entry %1.").arg(entry->title()) << endl;
+ out << QObject::tr("Successfully edited entry %1.").arg(entry->title()) << endl;
return EXIT_SUCCESS;
}