adamabdelhamed / PowerArgs

The ultimate .NET Standard command line argument parser
MIT License
569 stars 56 forks source link

Implementation of ContextAssistSearch doesn't get initialized #146

Closed ghost closed 2 years ago

ghost commented 4 years ago

I've added an implementation of ContextAssistSearch in my project. During testing, I noticed that the implementation never got initialized respectively GetResults never got called. To verify, I've build the git example and had the same behavior.

Is this still supported or what is the correct way to provide a dynamic resolution of an argument?

internal class ConfigurationElementNameContextAssistSearch : ContextAssistSearch
{
    public override bool SupportsAsync => true;

    public ConfigurationElementNameContextAssistSearch()
    {
    }

    protected override List<ContextAssistSearchResult> GetResults(string searchString)
    {
        ...
    }

    protected override Task<List<ContextAssistSearchResult>> GetResultsAsync(string searchString)
    {
        throw new System.NotImplementedException();
    }
}

public class ConfigurationManipulatorArgs
{
    [ArgRequired, ArgDescription("The action to run."), ArgPosition(1), PromptIfEmpty]
    [ArgumentAwareTabCompletion(typeof(ConfigurationManipulatorActionTabCompletionSource))]
    public ConfigurationManipulatorAction Action { get; set; }

    [ArgRequired, ArgDescription("The item to work with."), ArgPosition(2), PromptIfEmpty]
    [ArgumentAwareTabCompletion(typeof(ConfigurationElementTabCompletionSource))]
    public ConfigurationElement Item { get; set; }

    [ArgDescription("Which item to update or remove."), ArgPosition(3), PromptIfEmpty]        
    [ArgContextualAssistant(typeof(ConfigurationElementNameContextAssistSearch))]
    public string Name { get; set; }       
}
adamabdelhamed commented 3 years ago

Context assist only gets enabled if you have the [TabCompletion] attribute and the user presses CTRL + Space to activate the assistant. I have a feeling you were trying to accomplish something else. I know this is a pretty old issue, but if you are willing to elaborate on what you were trying to do then I can help.