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

Viper flags should use conts #81

Open
ninjamast3r opened this issue Feb 2, 2024 · 1 comment
Open

Viper flags should use conts #81

ninjamast3r opened this issue Feb 2, 2024 · 1 comment

Comments

@ninjamast3r
Copy link
Collaborator

To avoid getting flags out of sync if we ever change them, the viper names should use constants. So instead of:

cmd.Flags().String("foo", "", "it does stuff")
...
foo := viper.GetString("foo")

do this:

const fooFlag := "foo"
cmd.Flags().String(fooFlag , "", "it does stuff")
...
foo := viper.GetString(fooFlag )

Keep the flags related to whatever commands they reference. No need to reference variables from way across the project.

@xbcsmith xbcsmith mentioned this issue Feb 2, 2024
@caproven
Copy link
Collaborator

caproven commented Feb 8, 2024

Cobra/viper related & could possibly be looked at when handling this issue:

I've noticed cli/cmd/root.go has 2 calls of viper.AutomaticEnv(). I haven't looked any further to see if one could be safely deleted, but imagine this is unintentional.

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

No branches or pull requests

2 participants