You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to append a new section to the current generated help using the method CustomizeLayout, but i can't and has no effect.
Something like:
publicvoidShowCustomHelp(){varsettings=newCliSettings{Output=newStringWriter(),Theme=CliTheme.Default};varparseResult=Cli.Parse<RootCliCommand>(["--help"],settings);if(parseResult.ActionisHelpActionhelpAction&&helpAction.BuilderisCliHelpBuildercliBuilder){cliBuilder.CustomizeLayout(context =>{vardefaultLayout=cliBuilder.GetLayout(context);returndefaultLayout.Concat([
ctx =>{ctx.Output.WriteLine("This is the footer text.");returntrue;}]);});(helpActionasSynchronousCommandLineAction)?.Invoke(parseResult);}Console.WriteLine(settings.Output.ToString());settings.Output.ToString().Should().Contain("This is the footer text.");}
HelpBuilder class in System.CommandLine provide a mechanism to Customize help layout by passing a delegate of type Func<HelpContext, IEnumerable<Func<HelpContext, bool>>> to the method CustomizeLayout
The customization allowing add or replace a new section to the generated help at runtime.
The Root cause:
The method CustomizeLayout store the getLayout delegate in a private field _getLayout
This private field _getLayout is in the base class HelpBuilder in System.Commandline is not accessible by the class CliHelpBuilder.
CliHelpBuilder need to be modified to support CustomizeLayout
I can provide PR to fix this issue if you like.
The text was updated successfully, but these errors were encountered:
moh-hassan
added a commit
to moh-hassan/command-line
that referenced
this issue
Feb 15, 2025
I tried to append a new section to the current generated help using the method
CustomizeLayout
, but i can't and has no effect.Something like:
HelpBuilder class in System.CommandLine provide a mechanism to Customize help layout by passing a delegate of type
Func<HelpContext, IEnumerable<Func<HelpContext, bool>>>
to the method CustomizeLayoutThe customization allowing add or replace a new section to the generated help at runtime.
The Root cause:
The method
CustomizeLayout
store the getLayout delegate in a private field _getLayoutThis private field
_getLayout
is in the base classHelpBuilder
inSystem.Commandline
is not accessible by the class CliHelpBuilder.CliHelpBuilder need to be modified to support
CustomizeLayout
I can provide PR to fix this issue if you like.
The text was updated successfully, but these errors were encountered: