spectreconsole / spectre.console

A .NET library that makes it easier to create beautiful console applications.
https://spectreconsole.net
MIT License
9.17k stars 472 forks source link

[Feature Request] Autocomplete Support #1243

Open JKamsker opened 1 year ago

JKamsker commented 1 year ago

Is your feature request related to a problem? Please describe.

I'm always frustrated when using the spectre.console library in C# because it lacks autocomplete support. Without autocomplete, it becomes challenging and time-consuming to enter commands, arguments, and their values accurately. I have tried implementing autocomplete on my own for my project, but unfortunately, I was unsuccessful.

Describe alternatives you've considered

I have explored various alternatives in order to implement autocomplete functionality for my project. One approach I tried was to write the autocomplete feature from scratch, but unfortunately, my attempts were unsuccessful. Building a reliable and efficient autocomplete feature requires a considerable amount of time and effort.

As an alternative, I looked for existing libraries or frameworks that provide autocomplete functionality. However, my search did not yield any suitable options. Despite my efforts, I was unable to find a library that specifically addresses my requirements.

Considering the challenges I encountered and the lack of suitable alternatives, I believe it would be highly beneficial to have the autocomplete feature integrated into the spectre.console library as a built-in feature. This would not only save time and effort but also ensure a reliable and efficient implementation of the desired functionality.

Describe the solution you'd like

I would like the spectre.console library to have built-in autocomplete support similar to the "winget complete" command in the Windows Package Manager (winget) tool.

The autocomplete feature should provide:

For example:

RegisterAutocompleteCommand("spectre", (wordToComplete, commandAst, cursorPosition) =>
{
    // Autocomplete logic goes here
    // Return a list of completions based on the provided parameters
});

Additional context

Here is a sample call of the "winget complete" command for reference:

winget complete --word "c" --commandline "winget c" --position 7

Expected result:

config
complete

Please upvote :+1: this issue if you are interested in it.

nils-a commented 1 year ago

Possible duplicate of #267

JKamsker commented 1 year ago

Implemented in https://github.com/spectreconsole/spectre.console/pull/1260

patriksvensson commented 1 year ago

@JKamsker We keep issues open until the corresponding PR has been merged 😃

Kissaki commented 2 months ago

Nushell can use value + description for auto-completion - listing not only the options but also describing them. It would be nice if command descriptions could be used too (they can already be described with attributes for the help text), and maybe even any suggestions (static and dynamic suggestions).