blob: a708a8893a7370fd49bcac7ee60bbf191dca0644 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# PowerShell parameter completion for xmake
Register-ArgumentCompleter -Native -CommandName xmake -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
$complete = "$wordToComplete"
if (-not $commandName) {
$complete = $complete + " "
}
$oldenv = $env:XMAKE_SKIP_HISTORY
$oldcolor = $env:XMAKE_COLORTERM
$env:XMAKE_SKIP_HISTORY = 1
$env:XMAKE_COLORTERM = "nocolor"
$results = xmake lua "private.utils.complete" $cursorPosition "nospace-json" "$complete" 2>$null | ConvertFrom-Json | Sort-Object -Property value
$results | ForEach-Object {
$hasdesc = [bool] $_.psobject.Properties['description']
if ($hasdesc) {
$desc = " - $($_.description)"
} else {
$desc = ""
}
[System.Management.Automation.CompletionResult]::new($_.value, "$($_.value)$desc", 'ParameterValue', $_.value)
}
$env:XMAKE_SKIP_HISTORY = $oldenv
$env:XMAKE_COLORTERM = $oldcolor
}
# PowerShell parameter completion for xrepo
Register-ArgumentCompleter -Native -CommandName xrepo -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
$complete = "$wordToComplete"
if (-not $commandName) {
$complete = $complete + " "
}
$oldenv = $env:XMAKE_SKIP_HISTORY
$oldcolor = $env:XMAKE_COLORTERM
$env:XMAKE_SKIP_HISTORY = 1
$env:XMAKE_COLORTERM = "nocolor"
$results = xmake lua "private.xrepo.complete" $cursorPosition "nospace-json" "$complete" 2>$null | ConvertFrom-Json | Sort-Object -Property value
$results | ForEach-Object {
$hasdesc = [bool] $_.psobject.Properties['description']
if ($hasdesc) {
$desc = " - $($_.description)"
} else {
$desc = ""
}
[System.Management.Automation.CompletionResult]::new($_.value, "$($_.value)$desc", 'ParameterValue', $_.value)
}
$env:XMAKE_SKIP_HISTORY = $oldenv
$env:XMAKE_COLORTERM = $oldcolor
}
|