CLI Command cleanup

This PR cleans up the `Command` classes in the CLI, introducing a
`DatabaseCommand` class for the commands operating on a database,
and a `getCommandLineParser` command to centralize the arguments
parsing and validation.

The opening of the database based on the CLI arguments and options
is now centralized in `DatabaseCommand.execute`, making it easy to
add new database opening features (like YubiKey support for the CLI).

Also a couple of bugs fixed:
  * `Create` was still using `stdout` for some error messages.
  * `Diceware` and `Generate` were not validating that the word count was an integer.
  * `Diceware` was also using `stdout` for some error messages.
This commit is contained in:
louib
2019-06-01 17:53:40 -04:00
committed by Jonathan White
parent 3cf171cbf5
commit 04360ed552
31 changed files with 591 additions and 637 deletions

View File

@@ -18,17 +18,15 @@
#ifndef KEEPASSXC_REMOVE_H
#define KEEPASSXC_REMOVE_H
#include "Command.h"
#include "DatabaseCommand.h"
#include "core/Database.h"
class Remove : public Command
class Remove : public DatabaseCommand
{
public:
Remove();
~Remove();
int execute(const QStringList& arguments) override;
int removeEntry(Database* database, const QString& databasePath, const QString& entryPath, bool quiet);
int executeWithDatabase(QSharedPointer<Database> db, QSharedPointer<QCommandLineParser> parser);
};
#endif // KEEPASSXC_REMOVE_H