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:
Jonathan White
2020-05-11 07:31:29 -04:00
parent 612f8d2e5b
commit 485852c9db
30 changed files with 938 additions and 1407 deletions

View File

@@ -48,7 +48,7 @@ Estimate::Estimate()
static void estimate(const char* pwd, bool advanced)
{
TextStream out(Utils::STDOUT, QIODevice::WriteOnly);
auto& out = Utils::STDOUT;
int len = static_cast<int>(strlen(pwd));
if (!advanced) {
@@ -163,14 +163,14 @@ int Estimate::execute(const QStringList& arguments)
return EXIT_FAILURE;
}
TextStream inputTextStream(Utils::STDIN, QIODevice::ReadOnly);
auto& in = Utils::STDIN;
const QStringList args = parser->positionalArguments();
QString password;
if (args.size() == 1) {
password = args.at(0);
} else {
password = inputTextStream.readLine();
password = in.readLine();
}
estimate(password.toLatin1(), parser->isSet(Estimate::AdvancedOption));