Tyrrrz / CliFx

Class-first framework for building command-line interfaces
MIT License
1.48k stars 60 forks source link

Implement autocompletion #96

Closed mauricel closed 3 years ago

mauricel commented 3 years ago

Demo pull request for #13 -- good enough to demo.

To try out, use this powershell snippet.

    $scriptblock = {
    param($wordToComplete, $commandAst, $cursorPosition)
        # assumes exe is not somewhere random on the path
        $command = ".\CliFx.Demo"

        &$command `[suggest`] $commandAst | ForEach-Object {
            [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
        }
}

Register-ArgumentCompleter -Native -CommandName CliFx.Demo -ScriptBlock $scriptblock

Still to do: