Skip to content

Inconsistent preserving of trailing period in help descriptions #1729

Closed
@TheTonttu

Description

@TheTonttu

Information

  • OS: Windows 10 22H2 (build 19045.5247)
  • Version: 0.49.1
  • Terminal: Windows Terminal

Describe the bug
When IConfigurator.TrimTrailingPeriods(false), trailing periods in the command descriptions are preserved but not in the argument or option descriptions.

To Reproduce
Run the below application dotnet run -- example --help and see the output.

Application

using Spectre.Console.Cli;
using System.ComponentModel;

internal sealed class Program
{
    private static int Main(string[] args)
    {
        var app = new CommandApp();

        app.Configure(cfg =>
        {
            cfg.TrimTrailingPeriods(false);
            cfg.AddCommand<ExampleCommand>("example");
        });

        return app.Run(args);
    }
}

[Description("Example command description with trailing period. Trailing period is preserved as expected.")]
internal sealed class ExampleCommand : Command<ExampleCommandSettings>
{
    public override int Execute(CommandContext context, ExampleCommandSettings settings)
    {
        return 0;
    }
}

internal sealed class ExampleCommandSettings : CommandSettings
{
    [CommandArgument(0, "<EXAMPLE>")]
    [Description("Example argument description with trailing period. Looks silly when trailing period is removed from description with multiple sentences.")]
    public string ExampleArgument { get; set; } = string.Empty;

    [CommandOption("-e|--example <VALUE>")]
    [Description("""
        Example option description with trailing period.
        
        Looks silly when trailing period is removed from multiline description.
        """)]
    public string ExampleOption { get; set; } = string.Empty;
}

Output

DESCRIPTION:
Example command description with trailing period. Trailing period is preserved as expected.

USAGE:
    TrailingPeriodTrimming.dll example <EXAMPLE> [OPTIONS]

ARGUMENTS:
    <EXAMPLE>    Example argument description with trailing period. Looks silly when trailing period is removed from
                 description with multiple sentences

OPTIONS:
    -h, --help               Prints help information
    -e, --example <VALUE>    Example option description with trailing period.

                             Looks silly when trailing period is removed from multiline description

Expected behavior
Trailing period is preserved in all descriptions when IConfigurator.TrimTrailingPeriods(false).


Please upvote 👍 this issue if you are interested in it.

Metadata

Metadata

Assignees

Labels

area-CLICommand-Line InterfacebugSomething isn't working

Type

Projects

  • Status

    Done 🚀

Relationships

None yet

Development

No branches or pull requests

Issue actions