diff options
Diffstat (limited to 'src/cli/Remove.cpp')
-rw-r--r-- | src/cli/Remove.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/cli/Remove.cpp b/src/cli/Remove.cpp index e0dc0d58a..6a3a87b00 100644 --- a/src/cli/Remove.cpp +++ b/src/cli/Remove.cpp @@ -37,15 +37,13 @@ Remove::Remove() int Remove::executeWithDatabase(QSharedPointer<Database> database, QSharedPointer<QCommandLineParser> parser) { - bool quiet = parser->isSet(Command::QuietOption); - auto& entryPath = parser->positionalArguments().at(1); - - TextStream outputTextStream(quiet ? 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; + auto& entryPath = parser->positionalArguments().at(1); QPointer<Entry> entry = database->rootGroup()->findEntryByPath(entryPath); if (!entry) { - errorTextStream << QObject::tr("Entry %1 not found.").arg(entryPath) << endl; + err << QObject::tr("Entry %1 not found.").arg(entryPath) << endl; return EXIT_FAILURE; } @@ -61,14 +59,14 @@ int Remove::executeWithDatabase(QSharedPointer<Database> database, QSharedPointe QString errorMessage; if (!database->save(&errorMessage, true, false)) { - errorTextStream << QObject::tr("Unable to save database to file: %1").arg(errorMessage) << endl; + err << QObject::tr("Unable to save database to file: %1").arg(errorMessage) << endl; return EXIT_FAILURE; } if (recycled) { - outputTextStream << QObject::tr("Successfully recycled entry %1.").arg(entryTitle) << endl; + out << QObject::tr("Successfully recycled entry %1.").arg(entryTitle) << endl; } else { - outputTextStream << QObject::tr("Successfully deleted entry %1.").arg(entryTitle) << endl; + out << QObject::tr("Successfully deleted entry %1.").arg(entryTitle) << endl; } return EXIT_SUCCESS; |