mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-01-06 19:15:38 -05: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:
parent
d09ca076dc
commit
726bbb2d94
12 changed files with 80 additions and 82 deletions
|
|
@ -156,8 +156,8 @@ static void estimate(const char* pwd, bool advanced)
|
|||
|
||||
int Estimate::execute(const QStringList& arguments)
|
||||
{
|
||||
TextStream in(Utils::STDIN, QIODevice::ReadOnly);
|
||||
TextStream out(Utils::STDOUT, QIODevice::WriteOnly);
|
||||
TextStream inputTextStream(Utils::STDIN, QIODevice::ReadOnly);
|
||||
TextStream errorTextStream(Utils::STDERR, QIODevice::WriteOnly);
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription(description);
|
||||
|
|
@ -171,7 +171,7 @@ int Estimate::execute(const QStringList& arguments)
|
|||
|
||||
const QStringList args = parser.positionalArguments();
|
||||
if (args.size() > 1) {
|
||||
out << parser.helpText().replace("keepassxc-cli", "keepassxc-cli estimate");
|
||||
errorTextStream << parser.helpText().replace("keepassxc-cli", "keepassxc-cli estimate");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ int Estimate::execute(const QStringList& arguments)
|
|||
if (args.size() == 1) {
|
||||
password = args.at(0);
|
||||
} else {
|
||||
password = in.readLine();
|
||||
password = inputTextStream.readLine();
|
||||
}
|
||||
|
||||
estimate(password.toLatin1(), parser.isSet(advancedOption));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue