Skip to content

Completions can be called from Help and it's hard to make the distinction #1584

Open
@guillaume86

Description

@guillaume86

Currently if I don't want to show completions in the help text, I have to ressort to this method to detect if that was the help that called my completions (and that only works because I use subcommands):

private static bool IsHelpCall(CompletionContext context)
{
    return context.ParseResult.CommandResult?.Command is RootCommand;
}

I'd like to have an API for this, maybe adding an enum "InvocationContext(Suggest|ShowHelp)" to the CompletionContext?

It's not crucial to the issue but here are a few reasons I want to show different results:

  • completions can be slow to return
  • there can be a lot of results, especially if WordToComplete is empty
  • I just don't want to show them in the help text

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CompletionsRelated to support for tab completionArea-HelpbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions