Skip to content

Conversation

@ArmaanMcleod
Copy link
Contributor

@ArmaanMcleod ArmaanMcleod commented Mar 3, 2025

PR Summary

Extended IArgumentCompleter interface to include default methods and properties.

This is the alternative solution to the base class approach.

PR Context

Fixes #25033

PR Checklist

@ArmaanMcleod
Copy link
Contributor Author

@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 😄.

@ArmaanMcleod ArmaanMcleod changed the title Extend IArgumentCompleter interface with ArgumentCompleterOptions Extend IArgumentCompleter interface Mar 3, 2025
@ArmaanMcleod ArmaanMcleod requested a review from iSazonov March 3, 2025 14:25
@ArmaanMcleod
Copy link
Contributor Author

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 🙂.

@iSazonov
Copy link
Collaborator

iSazonov commented Mar 5, 2025

@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; }
Copy link
Collaborator

@iSazonov iSazonov Mar 5, 2025

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.

Copy link
Collaborator

@iSazonov iSazonov Mar 5, 2025

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.

@ArmaanMcleod ArmaanMcleod changed the title Extend IArgumentCompleter interface WIP: Extend IArgumentCompleter interface Mar 5, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Mar 8, 2025
@iSazonov
Copy link
Collaborator

ShouldComplete

No need. Implementation can return just empty from source of completion values.

Completion values source.

We need two options to simplify common scenarios. (1) User assign an array values. (2) a method returns completion values.

Filtering

We need to generalize. Today we only use Wildcard.Ismatch(). I think this should be default for a delegate we use.

Quoting

It is not clear for me should we generalize this.

Sorting

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide base class or extend interface for Argument Completers

2 participants