-
Notifications
You must be signed in to change notification settings - Fork 8.1k
WIP: Extend IArgumentCompleter interface
#25116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Extend IArgumentCompleter interface
#25116
Conversation
|
@iSazonov Let me know what you think. This PR mostly extends the IArgumentCompleter interface with options. Easier to put all the options into a separate class than deal with many fields in the interface 😄. |
src/System.Management.Automation/engine/CommandCompletion/ExtensibleCompletion.cs
Outdated
Show resolved
Hide resolved
IArgumentCompleter interface with ArgumentCompleterOptionsIArgumentCompleter interface
|
Thanks @iSazonov for the initial review. After some more playing around it seems possible to just extend interface, I had to put some workarounds in. Let me know if you think this is on the right track 🙂. |
src/System.Management.Automation/engine/CommandCompletion/ExtensibleCompletion.cs
Outdated
Show resolved
Hide resolved
|
@ArmaanMcleod I see you implement common algorithm for quoting. I think it is useful in any case and suggest to open new PR to move this in main branch. This way there will be more arguments to promote the updated interface. |
| /// <summary> | ||
| /// Gets the name of the command that needs argument completion. | ||
| /// </summary> | ||
| protected static string? CommandName { get; private set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why static? I think it is unique per instance. And rather internal for the instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking more I believe all these members initially come from CompleteArgument() - they are dynamic. So it makes no sense to keep them.
IArgumentCompleter interfaceIArgumentCompleter interface
No need. Implementation can return just empty from source of completion values.
We need two options to simplify common scenarios. (1) User assign an array values. (2) a method returns completion values.
We need to generalize. Today we only use Wildcard.Ismatch(). I think this should be default for a delegate we use.
It is not clear for me should we generalize this.
If we look related RFC there is a request to support sorting. I think this is redundant since the order can be set in the completion value source. |
PR Summary
Extended
IArgumentCompleterinterface to include default methods and properties.This is the alternative solution to the base class approach.
PR Context
Fixes #25033
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.- [ ] Issue filed:
(which runs in a different PS Host).