summaryrefslogtreecommitdiff
path: root/scripts/register-completions.ps1
blob: a9ecd7877bbf7bad11f7486f04aa004f1cf12d06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# PowerShell parameter completion shim for xmake

Register-ArgumentCompleter -Native -CommandName xmake -ScriptBlock {
    param($commandName, $wordToComplete, $cursorPosition)
    $complete = "$wordToComplete"
    if (-not $commandName) {
        $complete = $complete + " "
    }
    $oldenv = $env:XMAKE_SKIP_HISTORY
    $env:XMAKE_SKIP_HISTORY = 1
    xmake lua --root private.utils.complete "0" "nospace" "$complete" | ForEach-Object {
        [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
    }
    $env:XMAKE_SKIP_HISTORY = $oldenv
}