Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent preserving of trailing period in help descriptions #1729

Open
TheTonttu opened this issue Jan 11, 2025 · 3 comments · May be fixed by #1740
Open

Inconsistent preserving of trailing period in help descriptions #1729

TheTonttu opened this issue Jan 11, 2025 · 3 comments · May be fixed by #1740
Labels
area-CLI Command-Line Interface bug Something isn't working needs triage

Comments

@TheTonttu
Copy link

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.

@TheTonttu TheTonttu added bug Something isn't working needs triage labels Jan 11, 2025
@github-project-automation github-project-automation bot moved this to Todo 🕑 in Spectre Console Jan 11, 2025
@FrankRay78 FrankRay78 added the area-CLI Command-Line Interface label Jan 14, 2025
@TheTonttu
Copy link
Author

If you don't mind I could take a look at this? It seems to be a minor oversight in the HelpProvider implementation.

@FrankRay78
Copy link
Contributor

Hello @TheTonttu, I would be happy to review/merge any PR you submit for this issue. I ported the old help provider into the current format and it wasn't exactly how I wanted it at the time.

@TheTonttu
Copy link
Author

Thanks @FrankRay78, I'll try to submit a PR sometime this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CLI Command-Line Interface bug Something isn't working needs triage
Projects
Status: Todo 🕑
Development

Successfully merging a pull request may close this issue.

2 participants