spectre.console
spectre.console copied to clipboard
WIP Fixes #267 completer
The goal of this pull request is to add out-of-the-box completer functionality to Spectre.Console, as suggested in #267.
The approach will be to mimic what a tool like dotnet complete does. As a result, the completion scripts that people can use, will be analogous to those for dotnet complete.
@patriksvensson @phil-scott-78 Do you feel am I taking this in the right direction? Today's start, to me, felt promising. Let me know your thoughts, and feel free to add (failing) tests to provide more specific direction. The current four tests pass.
I forgot to catch the actual parser error, so... I was accidentally muting an index out of bounds exception.. fixed now.
I'm going to pul this down tonight and play with it. So far it looks really cool.
One scenario that I was thinking about was being able to add a service to commands to specify valid values when they are resolved. E.g. when I type git add a<TAB> the add verb is clever enough to suggest dirty files starting with the letter a.
@phil-scott-78 I'm not entirely sure yet how to add what you mentioned above. Could you provide a pseudo code draft?
I added option parameter support and some more tests.
So my thought was given this settings
public class FooCommandSettings : CommandSettings
{
[CommandArgument(0, "[QUX]")]
[Description("The qux value.")]
public string Qux { get; set; }
}
Let's assume Qux might be a list of *.qux files in the current folder or sub-folder.
Someone types in myapp.exe p<TAB> the app would be able to autocompletion info in the form of all the files that are p*.qux.
To implement perhaps would work like the `ParameterValidationAttribute
public sealed class FileCompletionAttribute : ParameterValidationAttribute
{
public override string[] Complete(CommandParameterContext context, string partialElement)
{
return GetQuxCompletions(partialElement);
}
}
public class FooCommandSettings : CommandSettings
{
[CommandArgument(0, "[QUX]")]
[Description("The qux value.")]
[FileCompletionAttribute]
public string Qux { get; set; }
}
It's absolutely the next step and would be super cool to have. I'll have a look at where this would fit, thanks for the input, appreciate it!
Hello @Jawz84, I'm just checking in to see if you made any further progress with this PR?
Hi Frank, thank you for checking in. I'm afraid life happened and I have since not continued the PR. I don't think I will continue it either. It's been so long and lots of other things are happening. Sorry to disappoint.
Met vriendelijke groet,
Jos Koelewijn
From: Frank Ray @.> Sent: Saturday, May 13, 2023 9:21:41 PM To: spectreconsole/spectre.console @.> Cc: Jos Koelewijn @.>; Mention @.> Subject: Re: [spectreconsole/spectre.console] WIP Fixes #267 completer (PR #727)
Hello @Jawz84https://github.com/Jawz84, I'm just checking in to see if you made any further progress with this PR?
— Reply to this email directly, view it on GitHubhttps://github.com/spectreconsole/spectre.console/pull/727#issuecomment-1546734534, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGJ5E5J5UQRAEYAI5ZNCIH3XF7NMLANCNFSM5NU77RXA. You are receiving this because you were mentioned.Message ID: @.***>
Thanks for replying @Jawz84 , it's no disappointment and all contributions, even unmerged WIP PRs are appreciated. I was just doing some housekeeping across the open issues and PRs to check on any progress.
Regarding tab completion, and whilst I don't know anything about MacOS and Linux, it seems more involved than it first appears: https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete ie. each shell seems to need custom configuration manually added before tab completion actually works
Anyhow, I'm going to close this PR given your comment above and you can always come back to it later if you so desire. Or not. Take care
Thank you Frank!
From: Frank Ray @.> Sent: Monday, May 15, 2023 11:57:12 AM To: spectreconsole/spectre.console @.> Cc: Jos Koelewijn @.>; Mention @.> Subject: Re: [spectreconsole/spectre.console] WIP Tab completion for CLI (PR #727)
Thanks for replying @Jawz84https://github.com/Jawz84 , it's no disappointment and all contributions, even unmerged WIP PRs are appreciated. I was just doing some housekeeping across the open issues and PRs to check on any progress.
Regarding tab completion, and whilst I don't know anything about MacOS and Linux, it seems more involved than it first appears: https://learn.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete ie. each shell seems to need custom configuration manually added before tab completion actually works
Anyhow, I'm going to close this PR given your comment above and you can always come back to it later if you so desire. Or not. Take care
— Reply to this email directly, view it on GitHubhttps://github.com/spectreconsole/spectre.console/pull/727#issuecomment-1547544779, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGJ5E5JDZIR53TAFQE7DXQ3XGH4XRANCNFSM5NU77RXA. You are receiving this because you were mentioned.Message ID: @.***>