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

Feature Request: Add Examples section in HelpBuilder. #2510

Open
moh-hassan opened this issue Jan 13, 2025 · 5 comments
Open

Feature Request: Add Examples section in HelpBuilder. #2510

moh-hassan opened this issue Jan 13, 2025 · 5 comments

Comments

@moh-hassan
Copy link

The current help is generated based on the Description of Command/Option or Argument.
Most of cli tools provide examples in help.
It is needed to add a separate section appended to the current generated help for every Command.
The Examples can be a string property (like Description) in CliCommand to be used in configuring help examples every command.

In the article Add or replace help sections, we can add a new section , but it need to access a property Eg Examples
It is nice of that ExampleSection be part of HelpBuilder class .
Sample of the help with examples:

Description:
  Read a file

Usage:
  scl [options]

Options:
  --file <file>                                               The file to print out. [default: scl.runtimeconfig.json]
  --light-mode                                                Determines whether the background color will be black or
                                                              white
  --color                                                     Specifies the foreground color of console output
  <Black|Blue|Cyan|White>
  --version                                                   Show version information
  -?, -h, --help                                              Show help and usage information
 
Examples:
Example 1: 
scl --file  file.txt --color Cyan
Example 2: Using default color  
scl --file  file.txt
@moh-hassan
Copy link
Author

moh-hassan commented Jan 28, 2025

Is there any response for this issue.

The necessary change for this feature is adding Examples property to Symbol class

        public string? Examples{ get; set; }

and we can use the add-or-replace-help-sections to add help examples section to avoid changes in HelpBuilder class.

@KalleOlaviNiemitalo
Copy link

You can define an interface for getting examples, implement that in command classes, and make the help code use it if available. See Microsoft.TemplateEngine.Cli.Commands.ICustomHelp for a similar implementation.

@moh-hassan
Copy link
Author

Thanks @KalleOlaviNiemitalo for you suggestion.
What about the suggestion of adding property to the Symbol class

@KalleOlaviNiemitalo
Copy link

I hope the developers will concentrate on releasing a stable version of System.CommandLine, before they spend time on features like this that can be implemented in individual applications.

@moh-hassan
Copy link
Author

Ok, that is right.
Thanks

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

No branches or pull requests

2 participants