-
-
Notifications
You must be signed in to change notification settings - Fork 262
Show enum values as argument in help text #276
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
Show enum values as argument in help text #276
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start! I made a few suggestions below, but overall I like it. The approach here is simple and clean. Thanks!
I suspect this doesn't work on attributes? Have you tried it on a small program like this?
enum Color { Red, Blue }
class Program
{
[Option]
public Color Color { get; }
}|
Also, it looks like there are some test failures on Linux. It looks to me like the HangingIndentWriter is adding new lines, possibly because it is detecting Relevant code to look at: CommandLineUtils/src/CommandLineUtils/HelpText/DefaultHelpTextGenerator.cs Lines 313 to 329 in 76413af
CommandLineUtils/src/CommandLineUtils/HelpText/HangingIndentWriter.cs Lines 16 to 34 in 76413af
|
d0d2506 to
322363d
Compare
|
PR ready for review again |
When options or arguments are parsed into an enum, the help text will now include the values contained in the enum. fixes natemcmaster#92
Co-Authored-By: Nate McMaster <[email protected]>
Co-Authored-By: Nate McMaster <[email protected]>
Used e.g. for testing. Also made the default constructor public. This allows the DefaultHelpTextGenerator to be instantiated on a per-use basis in order to keep unit tests a isolated from each other as possible. Without that change, all instances would be the same singleton instance - i.e. a test can affect another test by fiddling with the overridden width.
Even though a CommandLineApplication holds lists of `CommandArgument` and `CommandOption` they are not used in the default help text generation.
322363d to
18bb134
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating! I had a just a few more comments to address about the new public APIs added. Once addressed, I’ll merge this in. I’m planning for this to be part of 2.5, planning to release in a few weeks.
When options or arguments are parsed into an enum, the help text will now include the values contained in the enum.
fixes #92