Adding debug info to CLI.

Adding debug info to the CLI and the general option
of the main Qt app. Also took time to:
* use `EXIT_SUCCESS`/`EXIT_FAILURE` constants
for main.cpp (this is what is used in `src/cli`);
* fixed `m_initalized` typo;
* added info on debugging mode being disabled
or not;
* regrouped Qt related stuff in the debug output.
This commit is contained in:
louib 2019-02-18 20:17:28 -05:00 committed by Jonathan White
parent 76913a5dd1
commit a58e3d5ee0
11 changed files with 126 additions and 82 deletions

View file

@ -56,6 +56,9 @@ Shows the title, username, password, URL and notes of a database entry. Can also
.SS "General options"
.IP "--debug-info"
Displays debugging information.
.IP "-k, --key-file <path>"
Specifies a path to a key file for unlocking the database. In a merge operation this option is used to specify the key file path for the first database.
@ -66,7 +69,7 @@ Silence password prompt and other secondary outputs.
Displays help information.
.IP "-v, --version"
Shows the program version.
Displays the program version.
.SS "Merge options"

View file

@ -26,6 +26,7 @@
#include "config-keepassx.h"
#include "core/Bootstrap.h"
#include "core/Tools.h"
#include "crypto/Crypto.h"
#if defined(WITH_ASAN) && defined(WITH_LSAN)
@ -60,6 +61,9 @@ int main(int argc, char** argv)
parser.addPositionalArgument("command", QObject::tr("Name of the command to execute."));
QCommandLineOption debugInfoOption(QStringList() << "debug-info",
QObject::tr("Displays debugging information."));
parser.addOption(debugInfoOption);
parser.addHelpOption();
parser.addVersionOption();
// TODO : use the setOptionsAfterPositionalArgumentsMode (Qt 5.6) function
@ -72,6 +76,10 @@ int main(int argc, char** argv)
// Switch to parser.showVersion() when available (QT 5.4).
out << KEEPASSXC_VERSION << endl;
return EXIT_SUCCESS;
} else if (parser.isSet(debugInfoOption)) {
QString debugInfo = Tools::debugInfo().append("\n").append(Crypto::debugInfo());
out << debugInfo << endl;
return EXIT_SUCCESS;
}
parser.showHelp();
}