Skip to content

✨✨ CLI Command cleanup ✨✨#3210

Merged
droidmonkey merged 1 commit intokeepassxreboot:developfrom
louib:cli_command_cleanup
Jun 14, 2019
Merged

✨✨ CLI Command cleanup ✨✨#3210
droidmonkey merged 1 commit intokeepassxreboot:developfrom
louib:cli_command_cleanup

Conversation

@louib
Copy link
Copy Markdown
Member

@louib louib commented Jun 2, 2019

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.

@droidmonkey let me know what you think! I believe with this PR merged, adding new commands or new database opening features will be faster and safer.

@phoerious can you take a look at how I'm using the QSharedPointer for the QCommandLineParser?? It's my first time using anything other than "vanilla" pointers.

Type of change

  • ✅ Bug fix (non-breaking change which fixes an issue)
  • ✅ Refactor (significant modification to existing code)

Testing strategy

  • existing unit tests
  • some new unit tests
  • tested locally with most of the commands

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]
  • ✅ I have added tests to cover my changes.

@louib louib added feature: CLI pr: refactoring Pull request refactors code labels Jun 2, 2019
@louib louib force-pushed the cli_command_cleanup branch from 5551375 to 8521d7c Compare June 3, 2019 00:16
@droidmonkey
Copy link
Copy Markdown
Member

There are not enough emoji's in this PR.

@droidmonkey droidmonkey added this to the v2.5.0 milestone Jun 3, 2019
@louib
Copy link
Copy Markdown
Member Author

louib commented Jun 3, 2019

@droidmonkey 🤣 🤣 we could add emoji quotas in the contributing guidelines

@droidmonkey
Copy link
Copy Markdown
Member

I'll digest this later in the week, first pass looks really really promising.

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.
Copy link
Copy Markdown
Member

@droidmonkey droidmonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic work.

@droidmonkey droidmonkey merged commit 04360ed into keepassxreboot:develop Jun 14, 2019
@louib louib deleted the cli_command_cleanup branch November 6, 2021 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: CLI pr: refactoring Pull request refactors code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants