mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-11-28 04:46:54 -08:00
We should output to stderr on EXIT_FAILURE (#2558)
Making sure we use stderr to output the help message when there is an invalid number of arguments, or when there's any error related to the arguments.
This commit is contained in:
1 parent
d09ca076dc
commit
726bbb2d94
12 files changed
+80
-82
No files matched your search
@@ -38,8 +38,8 @@ Diceware::~Diceware()
|
||||
|
||||
int Diceware::execute(const QStringList& arguments)
|
||||
{
|
||||
TextStream in(Utils::STDIN, QIODevice::ReadOnly);
|
||||
TextStream out(Utils::STDOUT, QIODevice::WriteOnly);
|
||||
TextStream outputTextStream(Utils::STDOUT, QIODevice::WriteOnly);
|
||||
TextStream errorTextStream(Utils::STDERR, QIODevice::WriteOnly);
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription(description);
|
||||
@@ -58,7 +58,7 @@ int Diceware::execute(const QStringList& arguments)
|
||||
|
||||
const QStringList args = parser.positionalArguments();
|
||||
if (!args.isEmpty()) {
|
||||
out << parser.helpText().replace("keepassxc-cli", "keepassxc-cli diceware");
|
||||
errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli diceware");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -78,12 +78,12 @@ int Diceware::execute(const QStringList& arguments)
|
||||
}
|
||||
|
||||
if (!dicewareGenerator.isValid()) {
|
||||
out << parser.helpText().replace("keepassxc-cli", "keepassxc-cli diceware");
|
||||
outputTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli diceware");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
QString password = dicewareGenerator.generatePassphrase();
|
||||
out << password << endl;
|
||||
outputTextStream << password << endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in new issue
Block a user