diff --git a/src/CommandLineUtils/CommandLineApplication.cs b/src/CommandLineUtils/CommandLineApplication.cs index 2b96f97b..238e948e 100644 --- a/src/CommandLineUtils/CommandLineApplication.cs +++ b/src/CommandLineUtils/CommandLineApplication.cs @@ -105,6 +105,7 @@ internal CommandLineApplication(CommandLineApplication parent, _services = new Lazy(() => new ServiceProvider(this)); ValueParsers = parent?.ValueParsers ?? new ValueParserProvider(); _clusterOptions = parent?._clusterOptions; + UsePagerForHelpText = parent?.UsePagerForHelpText ?? true; _conventionContext = CreateConventionContext(); @@ -172,7 +173,7 @@ public string Name /// /// Whether a Pager should be used to display help text. /// - public bool UsePagerForHelpText { get; set; } = true; + public bool UsePagerForHelpText { get; set; } /// /// All names by which the command can be referenced. This includes and an aliases added in . diff --git a/test/CommandLineUtils.Tests/CommandLineApplicationTests.cs b/test/CommandLineUtils.Tests/CommandLineApplicationTests.cs index bc05d8d0..29a526e3 100644 --- a/test/CommandLineUtils.Tests/CommandLineApplicationTests.cs +++ b/test/CommandLineUtils.Tests/CommandLineApplicationTests.cs @@ -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() {