Created
October 10, 2018 22:57
-
-
Save patriksvensson/e47cf103ccc9542939fc05a739211a38 to your computer and use it in GitHub Desktop.
Argument completer for Spectre.Cli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Register-ArgumentCompleter -Native -CommandName myapp -ScriptBlock { | |
param($commandName, $wordToComplete, $cursorPosition) | |
$split = $wordToComplete.ToString().Split() | |
$command = [system.String]::Join("_", $split[1..$split.Length]) | |
$position = ($cursorPosition-$split[0].Length - 1); | |
myapp complete --position $position "$command" | ForEach-Object { | |
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment