Skip to content

Possibility to disable suggestions in help output #2035

Open

Description

@mariopasquali

Suggestions are currently showing in the help output. This is not always the desired behavior, for example when suggestions are long, or when there are many. Let assume a path argument with suggestions made from the file system, it might not be desired that those suggestions are listed in the help output.

Ideally there should be a way to determine if suggestions are for the help output, so these could be customized in this case (not suggesting at all, providing only the first three, or any strategy). Or at the minimum, disable suggestions in help for specific arguments / options entirely.

Activity

  1. KalleOlaviNiemitalo commented on Jan 26, 2023

    @KalleOlaviNiemitalo

    AFAIK you can already hide the completions from help, by setting Argument.HelpName. See HelpBuilder.Default.GetArgumentUsageLabel:

    string firstColumn;
    var completions = (argument is { } a
    ? a.GetCompletions()
    : Array.Empty<CompletionItem>())
    .Select(item => item.Label)
    .ToArray();
    var arg = argument;
    var helpName = arg?.HelpName ?? string.Empty;
    if (!string.IsNullOrEmpty(helpName))
    {
    firstColumn = helpName!;
    }
    else if (completions.Length > 0)
    {
    firstColumn = string.Join("|", completions);
    }
    else
    {
    firstColumn = argument.Name;
    }

    Related performance issue dotnet/sdk#27374 (comment), #2038.

  2. mariopasquali commented on Jan 26, 2023

    @mariopasquali
    Author

    Wow, thank you, I totally missed that! It might not be the most obvious feature but it definitively does the job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CompletionsArea-Helpneeds documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions