Skip to content

Commit 08c6764

Browse files
vpkopylovnatemcmaster
authored andcommitted
UsePagerForHelpText property is inherited (#237)
* UsePagerForHelpText property is inherited * Remove redundant config from the test
1 parent e6e0a36 commit 08c6764

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/CommandLineUtils/CommandLineApplication.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ internal CommandLineApplication(CommandLineApplication parent,
105105
_services = new Lazy<IServiceProvider>(() => new ServiceProvider(this));
106106
ValueParsers = parent?.ValueParsers ?? new ValueParserProvider();
107107
_clusterOptions = parent?._clusterOptions;
108+
UsePagerForHelpText = parent?.UsePagerForHelpText ?? true;
108109

109110
_conventionContext = CreateConventionContext();
110111

@@ -172,7 +173,7 @@ public string Name
172173
/// <summary>
173174
/// Whether a Pager should be used to display help text.
174175
/// </summary>
175-
public bool UsePagerForHelpText { get; set; } = true;
176+
public bool UsePagerForHelpText { get; set; }
176177

177178
/// <summary>
178179
/// All names by which the command can be referenced. This includes <see cref="Name"/> and an aliases added in <see cref="AddName"/>.

test/CommandLineUtils.Tests/CommandLineApplicationTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,16 @@ public void InheritedHelpOptionCanBeOverridden()
786786
Assert.NotSame(help, sub2.OptionHelp);
787787
}
788788

789+
[Theory]
790+
[InlineData(false)]
791+
[InlineData(true)]
792+
public void UsePagerForHelpTextPropertyIsInherited(bool usePagerForHelpText)
793+
{
794+
var app = new CommandLineApplication { UsePagerForHelpText = usePagerForHelpText };
795+
var sub = app.Command("sub", _ => { });
796+
Assert.Equal(usePagerForHelpText, sub.UsePagerForHelpText);
797+
}
798+
789799
[Fact]
790800
public void VersionOptionIsSet()
791801
{

0 commit comments

Comments
 (0)