Introduce the keep verb#108
Conversation
| daemonCommand.PersistentFlags().StringP("clean", "c", config.ViperConfig.GetString("clean"), fmt.Sprintf("clean options before %s: %s", setupCommand.Name(), options.GetOptionNames(options.Clean{}))) | ||
| config.ViperConfig.BindPFlag("clean", daemonCommand.PersistentFlags().Lookup("clean")) | ||
|
|
||
| daemonCommand.PersistentFlags().StringP("keep", "k", config.ViperConfig.GetString("keep"), fmt.Sprintf("clean everything but the given options before %s: %s", setupCommand.Name(), options.GetOptionNames(options.Clean{}))) |
There was a problem hiding this comment.
What is the behaviour of keep if the setup command has never been called? Just a no-op?
There was a problem hiding this comment.
It's always called by clean.
As the workflow is clean -> setup -> run.
| setAll(opt) | ||
| setAllOptionsTo(opt, value) | ||
| reflect.ValueOf(opt).Elem().FieldByName("All").SetBool(value) | ||
| reflect.ValueOf(opt).Elem().FieldByName("None").SetBool(!value) |
There was a problem hiding this comment.
I'm not a huge fan of inspecting structs in this way but I do understand why you needed to do it in this case. Even if there was a way to refactor this it should probably be in a different PR, so I'll let it go for now.
There was a problem hiding this comment.
I know it's awful. I'm up for any improvement.
| // The clean string is lowercase clean options comma separated like: etcd,binaries ... | ||
| func NewCleanOptions(cleanString string) *Clean { | ||
| return newOptions(cleanString, &Clean{}).(*Clean) | ||
| // keepString takes precedence over the clean one |
There was a problem hiding this comment.
Can we add something like keepString takes precedence over the clean one in the docs for the keep command?
| } | ||
|
|
||
| func newOptions(stringOptions string, opt interface{}) interface{} { | ||
| func newOptions(stringOptions string, value bool, opt interface{}) interface{} { |
There was a problem hiding this comment.
Can you rename the local variable value to drain/clean maybe?
There was a problem hiding this comment.
What do you think of something like enabled?
What does this PR do?
Replace the non documented
--clean -binariesMotivation
Add a quicker way to plays with the options.