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

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

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