Skip to content

Conversation

@dwincort
Copy link
Contributor

As mentioned in #61, it would be nice if default values showed up in help messages. This PR implements such a change that I'm using personally and thought might be desired upstream.

This is a small change so that a field with <!> "defaultValue" will show (Default: defaultValue) in the help string. I opted to put this in the parseFields definition, which means that the order of field decorators now matters: that is, if one writes ... <!> "1" <?> "Field help", then the help text will read Field help (Default: 1), but if the order is ... <?> "Field help" <!> "1", then the help text will read Field help. This is by design so that the behavior could be overridden if desired.

@Gabriella439
Copy link
Owner

I think the more idiomatic way to do this is by setting the showDefault option:

https://hackage.haskell.org/package/optparse-applicative-0.16.1.0/docs/Options-Applicative.html#v:showDefault

@dwincort
Copy link
Contributor Author

Ahh, I didn't know about that feature of optparse-applicative. Is there a straightforward way to set that from the optparse-generic interface?

@Gabriella439
Copy link
Owner

Oh, I mean that we can fix optparse-generic to automatically set showDefault on behalf of the user. I think we just forgot to set it as an oversight when adding support for default values

@dwincort
Copy link
Contributor Author

Yeah, this is simpler and (I think) more idiomatic.

@Gabriella439 Gabriella439 merged commit 9270f18 into Gabriella439:master Aug 30, 2021
@Gabriella439
Copy link
Owner

Thank you again for contributing this! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants