Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Cobra CLI tooling, Viper config tooling #336

Merged
merged 22 commits into from
Dec 7, 2021
Merged

Conversation

tsmethurst
Copy link
Contributor

@tsmethurst tsmethurst commented Dec 6, 2021

This pull request replaces the urfave cli tooling we were using, with Cobra, which provides a bit more flexible CLI functionality, and fixes some of the messy CLI code we had in the cmd folder where we had to work around some bugs and issues with urfave.

It also removes our current config implementation (passing a pointer to a static config struct around), and replaces it with a centralized configuration store provided by Viper.

This means that configuration can now be read from anywhere by calling the Viper singleton, without the need for an instantiated config struct. This is similar to the changes we made a while ago to our Logrus logging (use a global logger instead of passing the same logger pointer around everywhere).

This should pave the way to working on this issue: #270 , since Viper also allows 'watching' a config file and live reloading config, but that can be another PR.

BREAKING CHANGES !!!!

In order to implement cobra/viper properly, some of the configuration keys had to change. This has been updated in the documentation. When a release is done that includes this PR, we need a big WARNING on the PR to instruct people that they will probably have to update their config files / deployments with the new config keys.

Closes #42

@tsmethurst tsmethurst merged commit 0884f89 into main Dec 7, 2021
@tsmethurst tsmethurst deleted the cobra_and_viper branch December 7, 2021 12:31
leopku pushed a commit to leopku/gotosocial that referenced this pull request Dec 8, 2021
…ss#336)

* start pulling out + replacing urfave and config

* replace many many instances of config

* move more stuff => viper

* properly remove urfave

* move some flags to root command

* add testrig commands to root

* alias config file keys

* start adding cli parsing tests

* reorder viper init

* remove config path alias

* fmt

* change config file keys to non-nested

* we're more or less in business now

* tidy up the common func

* go fmt

* get tests passing again

* add note about the cliparsing tests

* reorganize

* update docs with changes

* structure cmd dir better

* rename + move some files around

* fix dangling comma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing CLI flag parsing
1 participant