dotnet / dotnet/command-line-api
dotnet-suggest: Completion when launching global tool via "dotnet"
- Lingua principale
- C#
- Stelle
- 3.7k
- Fork
- 428
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Tools that have a `dotnet-` prefix (e.g. `dotnet-monitor`) can be invoked via the main `dotnet` executable. I.e. you can launch a tool named `dotnet-monitor` by running `dotnet-monitor` or `dotnet monitor` (note the space). The latter simply results in `dotnet` launching the `dotnet-monitor` tool indirectly (so it's clearly less efficient), but from the user's perspective you get the same result.
The `dotnet-suggest` tool however only appears to successfully provide suggestions for tools that are directly invoked, even though such tools register both their potential entrypoints in `.dotnet-suggest-registration.txt`. I took a look at the code and the relevant part seems to be the `FormatSuggestionArguments` method in the `SuggestionDispatcher` class.
If the executable is `dotnet` it uses a different code path that strips the second token before passing it through to the target executable for suggestions. Some examples to help illustrate:
- `dotnet monitor` -> invokes `dotnet [suggest:0] ""`
- `dotnet monitor config` -> invokes `dotnet [suggest:6] "config"`
- `dotnet monitor config show` -> invokes `dotnet [suggest:11] "config show"`
I don't understand what this logic is trying to do. Is there some subtlety I'm missing here? Even if I manually send what I think should be the "correct" args to `dotnet` I still don't get back correct completions, e.g. `dotnet [suggest:13] "monitor config"`, so it's unclear if this is meant to work at all, or ever did. But in that case, why do tools using `System.CommandLine` register their `dotnet` aliases?
I am very confused ...
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia con il metodo FormatSuggestionArguments nella classe SuggestionDispatcher e segui il percorso separato executable-dotnet. Riproduci i comandi dotnet monitor elencati e confrontali con l’invocazione diretta dello strumento, quindi esamina la gestione di .dotnet-suggest-registration.txt e gli alias dotnet registrati. Il lavoro è completato quando gli strumenti con prefisso dotnet ricevono i completamenti corretti sia quando vengono avviati tramite dotnet sia direttamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp
- Ambito
- cli
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100