Adding --quiet option to the CLI. (#2507)

This commit is contained in:
louib
2018-11-28 11:24:12 -05:00
committed by Jonathan White
parent 4e49de1afb
commit fff0f11b33
21 changed files with 252 additions and 44 deletions

View File

@@ -25,9 +25,9 @@
#include "cli/TextStream.h"
#include "cli/Utils.h"
#include "core/Global.h"
#include "core/Database.h"
#include "core/Entry.h"
#include "core/Global.h"
#include "core/Group.h"
Locate::Locate()
@@ -48,6 +48,7 @@ int Locate::execute(const QStringList& arguments)
parser.setApplicationDescription(description);
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"));
@@ -61,7 +62,10 @@ int Locate::execute(const QStringList& arguments)
return EXIT_FAILURE;
}
auto db = Database::unlockFromStdin(args.at(0), parser.value(keyFile), Utils::STDOUT, Utils::STDERR);
auto db = Database::unlockFromStdin(args.at(0),
parser.value(keyFile),
parser.isSet(Command::QuietOption) ? Utils::DEVNULL : Utils::STDOUT,
Utils::STDERR);
if (!db) {
return EXIT_FAILURE;
}