Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankRay78 committed Jan 15, 2024
1 parent b3d9d99 commit 3c63f70
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/Spectre.Console.Cli/Help/HelpProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class HelpProvider : IHelpProvider
/// <remarks>
/// Useful for unit testing different styling of the same help text.
/// </remarks>
protected virtual bool RenderMarkupInline { get; }
protected virtual bool RenderMarkupInline { get; } = false;

private sealed class HelpArgument
{
Expand Down Expand Up @@ -115,8 +115,7 @@ public HelpProvider(ICommandAppSettings settings)
this.ShowOptionDefaultValues = settings.ShowOptionDefaultValues;
this.MaximumIndirectExamples = settings.MaximumIndirectExamples;
this.TrimTrailingPeriod = settings.TrimTrailingPeriod;
this.RenderMarkupInline = settings.RenderMarkupInline;
this.helpStyles = settings.HelpProviderStyles;
this.helpStyles = settings.HelpProviderStyles ?? HelpProviderStyle.Default;

resources = new HelpProviderResources(settings.Culture);
}
Expand Down
10 changes: 1 addition & 9 deletions src/Spectre.Console.Cli/ICommandAppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,10 @@ public interface ICommandAppSettings
/// </summary>
bool TrimTrailingPeriod { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to emit the markup styles, inline, when rendering the help text.
/// </summary>
/// <remarks>
/// Useful for unit testing different styling of the same help text.
/// </remarks>
bool RenderMarkupInline { get; set; }

/// <summary>
/// Gets or sets the styles to used when rendering the help text.
/// </summary>
HelpProviderStyle HelpProviderStyles { get; set; }
HelpProviderStyle? HelpProviderStyles { get; set; }

/// <summary>
/// Gets or sets the <see cref="IAnsiConsole"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ internal sealed class CommandAppSettings : ICommandAppSettings
public bool PropagateExceptions { get; set; }
public bool ValidateExamples { get; set; }
public bool TrimTrailingPeriod { get; set; }
public bool RenderMarkupInline { get; set; }
public HelpProviderStyle HelpProviderStyles { get; set; }
public HelpProviderStyle? HelpProviderStyles { get; set; }
public bool StrictParsing { get; set; }
public bool ConvertFlagsToRemainingArguments { get; set; }

Expand All @@ -32,7 +31,6 @@ public CommandAppSettings(ITypeRegistrar registrar)
ShowOptionDefaultValues = true;
MaximumIndirectExamples = 5;
TrimTrailingPeriod = true;
RenderMarkupInline = false;
HelpProviderStyles = HelpProviderStyle.Default;
ConvertFlagsToRemainingArguments = false;
}
Expand Down
11 changes: 11 additions & 0 deletions test/Spectre.Console.Cli.Tests/Data/Help/NoStylesHelpProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Spectre.Console.Cli.Tests.Data.Help;

internal class NoStylesHelpProvider : HelpProvider
{
protected override bool RenderMarkupInline { get; } = true;

public NoStylesHelpProvider(ICommandAppSettings settings)
: base(settings)
{
}
}
3 changes: 2 additions & 1 deletion test/Spectre.Console.Cli.Tests/Unit/CommandAppTests.Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,9 @@ public Task Should_Output_Default_Command_And_Additional_Commands_When_Default_C
fixture.SetDefaultCommand<LionCommand>();
fixture.Configure(configurator =>
{
configurator.Settings.PropagateExceptions = true;
configurator.AddExample("20", "--alive");
configurator.Settings.RenderMarkupInline = true;
configurator.SetHelpProvider<NoStylesHelpProvider>();
configurator.Settings.HelpProviderStyles = helpProviderStyle switch
{
"Default" => HelpProviderStyle.Default,
Expand Down

0 comments on commit 3c63f70

Please sign in to comment.