Proposal: automatically display default values of options in the help page
See original GitHub issueIs your feature request related to a problem? Please describe. This is not a problem but a proposal to improve the help page of CLI commands.
Describe the solution you’d like
Spectre.Console.Cli supports the DefaultValueAttribute
to specify a default value for a command option. It would be nice to use this information to automatically display default values in the help page.
Describe alternatives you’ve considered The current alternative is to repeat the default value in the option description text. This could easily lead to desynchronized documented default value and actual default value. Also, a new column would make the default values stand out.
Additional context Here’s what I quickly prototyped. I’ll submit a proper pull request if this idea is appealing to you.
Running the Demo example with run --help
before:
Running the Demo example with run --help
after:
Issue Analytics
- State:
- Created a year ago
- Comments:10 (10 by maintainers)
Top GitHub Comments
Good point! I have added a test covering this scenario in 47cd07027445e57e6eb53c2b303c973a82c6e826.
I think this is some good stuff as is. I’m gonna side with @0xced here, I think we could spend a ton of time trying to keep devs from shooting themselves in the foot with outrageous data but with this being something they are hard coding it isn’t like something an end user would be breaking.
I feel like this is in good shape. I want to pull it down later tonight after my little guy goes to bed and I’ll merge it in after my quick run through.
Long term @patriksvensson and I have discussed making a custom Help Writer something that could be plugged in. That way users wouldn’t need a million levers and buttons to toggle to get things to their liking - we could provide output that should meet most use cases but those that want to get into the weeds could use their own implementation.