Skip to content

Expose default values as a "Default" field on Options#4

Open
bobziuchkovski wants to merge 7 commits intomasterfrom
decouple-option-defaulter
Open

Expose default values as a "Default" field on Options#4
bobziuchkovski wants to merge 7 commits intomasterfrom
decouple-option-defaulter

Conversation

@bobziuchkovski
Copy link
Owner

@elithrar provided some great feedback on the default value handling. After some thought, I've put together a PR that decouples the OptionDefaulter and OptionDecoder interfaces. With this change, Options would have a separate Default field. As a result, string defaults can be assigned via opt.Default = writ.StringDefault("value"), and a ChainedDefault can be used to chain together defaults from a []Defaulter slice, returning the first non-empty default. This is how environment defaults are stacked with regular defaults with this PR.

If I merge this, I'll target the merge for the v1.0 release. I think I'll probably collect breaking changes and merge them to a separate 1.0-wip branch.

Only default option values for commands on the selected command path,
and only if the options have not been supplied values via arguments.
Rename the OptionDefaulter interface to Defaulter.  Now that it is
Decoupled from the OptionDecoder interface, the old name feels wrong.
Follow the more generic Go convention for single method interfaces.
@bobziuchkovski bobziuchkovski changed the title Decouple OptionDefaulter from OptionDecoder Expose default values as a "Default" field on Options Feb 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant