question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: automatically display default values of options in the help page

See original GitHub issue

Is 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: image

Running the Demo example with run --help after: image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
0xcedcommented, Dec 18, 2022

should we now add one test to include the output for when the user has opted-out of showing a default?

Good point! I have added a test covering this scenario in 47cd07027445e57e6eb53c2b303c973a82c6e826.

1reaction
phil-scott-78commented, Dec 18, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Set Default Values and Auto-Fill Form Fields
In the workflow editor, click the three dots at the top right of each field, then click Settings to access the default values,...
Read more >
Show Default Value in Text Field Until User Inputs Data
Specifies the text that appears until the user overwrites it by typing in the field. Enter the default value by typing in this...
Read more >
select-options default values
Hi. To assign default values to a selection criterion, you use the following syntax: SELECT-OPTIONS <seltab> FOR <f> DEFAULT <g> [TO <h>] ....
Read more >
Set a Default Value for Any Screen Component That ...
Want to set a default value for a choice component? ... The default value is automatically selected in the resulting list of choices....
Read more >
Solved: How to set a pre-populated default value of a Drop...
I'm currently trying to simply set the Default value of a Dropdown in an Edit Form (Form is opened and the Dropdown should...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found