DefiantLabs / cosmos-tax-cli

An opensource cosmos tax tool!
https://defiantlabs.net
Apache License 2.0
25 stars 7 forks source link

Refactor/465 cmd config rework #495

Closed pharr117 closed 11 months ago

pharr117 commented 11 months ago

Scope of this PR

This PR completely reworks the way commands receive the configuration values associated with them. It does this by splitting each command configuration out into its own block, allowing for per-command configuration requirements.

Old Methods

The old method used a single configuration setup for the entire application. This means every command required the exact same configuration, with each command only using the configs it needed to.

The commands also used the same setup function, which was an end-to-end setup of database connections, loggers etc...

New Methods

This PR introduces the following new behavior:

  1. Split of all configuration setups into discrete blocks
  2. Generalization of common configs and common validation methods for code reuse
  3. New PreRun functions for every command that handles getting and validating command configurations
  4. Removal of app-wide dependency on single setup function, each command only sets up what it needs

This achieves the following:

  1. Better code reuse
  2. Discrete commands allow for easier debugging and less downstream affects if things change
  3. Easier locations to establish common configurations and validations
  4. Better --help output for each command
  5. Smaller/better scoped config requirements for each command
danbryan commented 11 months ago

Hey, lets run over this in person before i merge it in as you suggested.