Skip to content

Commit

Permalink
UsePagerForHelpText property is inherited (#237)
Browse files Browse the repository at this point in the history
* UsePagerForHelpText property is inherited

* Remove redundant config from the test
  • Loading branch information
vpkopylov authored and natemcmaster committed May 24, 2019
1 parent e6e0a36 commit 08c6764
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

0 comments on commit 08c6764

Please sign in to comment.