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

UsePagerForHelpText property is inherited #237

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/CommandLineUtils/CommandLineApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ internal CommandLineApplication(CommandLineApplication parent,
_services = new Lazy<IServiceProvider>(() => new ServiceProvider(this));
ValueParsers = parent?.ValueParsers ?? new ValueParserProvider();
_clusterOptions = parent?._clusterOptions;
UsePagerForHelpText = parent?.UsePagerForHelpText ?? true;

_conventionContext = CreateConventionContext();

Expand Down Expand Up @@ -172,7 +173,7 @@ public string Name
/// <summary>
/// Whether a Pager should be used to display help text.
/// </summary>
public bool UsePagerForHelpText { get; set; } = true;
public bool UsePagerForHelpText { get; set; }

/// <summary>
/// All names by which the command can be referenced. This includes <see cref="Name"/> and an aliases added in <see cref="AddName"/>.
Expand Down
10 changes: 10 additions & 0 deletions test/CommandLineUtils.Tests/CommandLineApplicationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,16 @@ public void InheritedHelpOptionCanBeOverridden()
Assert.NotSame(help, sub2.OptionHelp);
}

[Theory]
[InlineData(false)]
[InlineData(true)]
public void UsePagerForHelpTextPropertyIsInherited(bool usePagerForHelpText)
{
var app = new CommandLineApplication { UsePagerForHelpText = usePagerForHelpText };
var sub = app.Command("sub", _ => { });
Assert.Equal(usePagerForHelpText, sub.UsePagerForHelpText);
}

[Fact]
public void VersionOptionIsSet()
{
Expand Down