mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-01-01 00:30:17 -05:00
Add CLI tests and improve coding style and i18n
The CLI module was lacking unit test coverage and showed some severe coding style violations, which this patch addresses. In addition, all uses of qCritical() with untranslatble raw char* sequences were removed in favor of proper locale strings. These are written to STDERR through QTextStreams and support output redirection for testing purposes. With this change, error messages don't depend on the global Qt logging settings and targets anymore and go directly to the terminal or into a file if needed. This patch also fixes a bug discovered during unit test development, where the extract command would just dump the raw XML contents without decrypting embedded Salsa20-protected values first, making the XML export mostly useless, since passwords are scrambled. Lastly, all CLI commands received a dedicated -h/--help option.
This commit is contained in:
parent
18b22834c1
commit
113c8eb702
67 changed files with 2259 additions and 1250 deletions
|
|
@ -25,7 +25,7 @@
|
|||
#include <cli/Command.h>
|
||||
|
||||
#include "config-keepassx.h"
|
||||
#include "core/Tools.h"
|
||||
#include "core/Bootstrap.h"
|
||||
#include "crypto/Crypto.h"
|
||||
|
||||
#if defined(WITH_ASAN) && defined(WITH_LSAN)
|
||||
|
|
@ -34,17 +34,17 @@
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
#ifdef QT_NO_DEBUG
|
||||
Tools::disableCoreDumps();
|
||||
#endif
|
||||
|
||||
if (!Crypto::init()) {
|
||||
qFatal("Fatal error while testing the cryptographic functions:\n%s", qPrintable(Crypto::errorString()));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
QCoreApplication app(argc, argv);
|
||||
app.setApplicationVersion(KEEPASSX_VERSION);
|
||||
QCoreApplication::setApplicationVersion(KEEPASSX_VERSION);
|
||||
|
||||
#ifdef QT_NO_DEBUG
|
||||
Bootstrap::bootstrapApplication();
|
||||
#endif
|
||||
|
||||
QTextStream out(stdout);
|
||||
QStringList arguments;
|
||||
|
|
@ -69,7 +69,7 @@ int main(int argc, char** argv)
|
|||
// recognized by this parser.
|
||||
parser.parse(arguments);
|
||||
|
||||
if (parser.positionalArguments().size() < 1) {
|
||||
if (parser.positionalArguments().empty()) {
|
||||
if (parser.isSet("version")) {
|
||||
// Switch to parser.showVersion() when available (QT 5.4).
|
||||
out << KEEPASSX_VERSION << endl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue