feat(config): add config overriding capability with pflags#30
feat(config): add config overriding capability with pflags#30deryrahman wants to merge 2 commits into
Conversation
9aa880f to
bfdb499
Compare
|
Since we don't expect Need to update the readme to add usage and remove todo point. |
@rohilsurana Yes it does. Would it be better if we use other func name? Or using this func name
Will do that |
|
That name looks good. |
| func main() { | ||
| var c Config | ||
| cmd := cobra.Command{} | ||
| cmd.Flags().Int("db-port", 5432, "set db port") |
There was a problem hiding this comment.
Looking at this usage example, can we automate setting the flag definitions?
Since we support setting the default values in the struct, there can be a mismatch in the value set by flag vs that in the struct. Basically we won't have a single source of truth.
So we have 2 options here -
- Support defining flags automatically with this config package (Not sure how complex this would be)
- Remove support for default values from struct and only use default values from flags. (Easy, but this option has an issue that folks not using flags will need to figure out their own way to set defaults)
There was a problem hiding this comment.
@rohilsurana @deryrahman Any final decision on this?
There was a problem hiding this comment.
not yet @ravisuhag , deferring the discussion as I haven't spiked the approach yet
I strongly suggest not to remove the support default values from struct. Will back to this once the spiking is done
|
#48 adds a way to override flags when using cmdx package as well. |
|
@rohilsurana yes, closing this for now. |
Providing capability to replace config via flags