Refactoring : Command base class for CLI commands#778
Refactoring : Command base class for CLI commands#778louib merged 1 commit intokeepassxreboot:developfrom
Conversation
563c01c to
1d3b811
Compare
1d3b811 to
e946644
Compare
| parser.showHelp(EXIT_FAILURE); | ||
| } | ||
|
|
||
| int exitCode = command->execute(argc, argv); |
There was a problem hiding this comment.
How about removing argv[0] (keepassxc) and lower argc by 1 here instead of doing it in every Command?
There was a problem hiding this comment.
@TheZ3ro the argv and argc have to be intact when instantiating the QApplication, otherwise the name of the app will be incorrect. I plan to only use QCoreApplication in the CLI in the future, so that we can instantiate it once in keepassxc-cli. This will require:
1- Using QProcess + native cli apps for clipping (already in progress)
2- Removing the gui prompt in favor of supporting a --key-file argument in all the CLI commands.
Until then, we have to rely on duplicating the code in the commands...
|
EntropyMeter need some love but the PR is ok, just take a look at the note above |
This PR introduces a
Commandclass, from which all the CLI commands inherit. This makes it easy to programmatically get the names of all the available commands, using the factory-like static functions in theCommandclass.Also took this opportunity to add most of the information on an entry to the
showcommand, and renamed thelistcommand tols, to fit the unix name.Motivation and context
This will make it easier to add new cli commands (there will be more in the future...)
How has this been tested?
Types of changes
Checklist:
-DWITH_ASAN=ON. [REQUIRED]