Skip to content

How to use Viper with Cobra? #1061

Discussion options

You must be logged in to vote

Historically both Viper and Cobra originate from Hugo, a static page generator, but the individual libraries don't have any tight integration between them. This might change in the future though: with Viper 2, consumers (like Cobra) will have much more control over how they integrate with Viper.

Nevertheless, it'll still be Cobra's job to handle the integration, not the other way around, so this probably won't be "fixed" on the Viper side.

Most of the issues are around handling flags. Internally, Cobra allows defining multiple FlagSets whereas usually there is only one Viper instance. This is a problem, when multiple FlagSets define the same flags.

Another common problem is Cobra's Required

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@justinfx
Comment options

Answer selected by sagikazarmark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants