mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-26 00:05:34 -04:00
CLI: Use stderr for password prompt
Fixes #3398. Convert to QTextStream for all CLI IO and greatly improve CLI tests * Completely overhaul CLI tests to be much more streamlined and easy to read. Removed unnecessary code blocks by using existing functions. Co-authored-by: Emma Brooks <me@pluvano.com>
This commit is contained in:
parent
612f8d2e5b
commit
485852c9db
30 changed files with 938 additions and 1407 deletions
|
@ -126,24 +126,24 @@ QString Command::getHelpText()
|
|||
|
||||
QSharedPointer<QCommandLineParser> Command::getCommandLineParser(const QStringList& arguments)
|
||||
{
|
||||
TextStream errorTextStream(Utils::STDERR, QIODevice::WriteOnly);
|
||||
auto& err = Utils::STDERR;
|
||||
QSharedPointer<QCommandLineParser> parser = buildParser(this);
|
||||
|
||||
if (!parser->parse(arguments)) {
|
||||
errorTextStream << parser->errorText() << "\n\n";
|
||||
errorTextStream << getHelpText();
|
||||
err << parser->errorText() << "\n\n";
|
||||
err << getHelpText();
|
||||
return {};
|
||||
}
|
||||
if (parser->positionalArguments().size() < positionalArguments.size()) {
|
||||
errorTextStream << getHelpText();
|
||||
err << getHelpText();
|
||||
return {};
|
||||
}
|
||||
if (parser->positionalArguments().size() > (positionalArguments.size() + optionalArguments.size())) {
|
||||
errorTextStream << getHelpText();
|
||||
err << getHelpText();
|
||||
return {};
|
||||
}
|
||||
if (parser->isSet(HelpOption)) {
|
||||
errorTextStream << getHelpText();
|
||||
err << getHelpText();
|
||||
return {};
|
||||
}
|
||||
return parser;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue