summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/register-completions.ps119
-rw-r--r--xmake/scripts/profile-win.ps119
2 files changed, 30 insertions, 8 deletions
diff --git a/scripts/register-completions.ps1 b/scripts/register-completions.ps1
index f19c48233..201f291cd 100755
--- a/scripts/register-completions.ps1
+++ b/scripts/register-completions.ps1
@@ -7,13 +7,19 @@ Register-ArgumentCompleter -Native -CommandName xmake -ScriptBlock {
}
$oldenv = $env:XMAKE_SKIP_HISTORY
$env:XMAKE_SKIP_HISTORY = 1
- xmake lua "private.utils.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value | ForEach-Object {
+ $results = xmake lua "private.utils.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value
+ $results | ForEach-Object {
$hasdesc = [bool] $_.psobject.Properties['description']
- $desc = $hasdesc ? " - $($_.description)" : ""
+ if ($hasdesc) {
+ $desc = " - $($_.description)"
+ } else {
+ $desc = ""
+ }
[System.Management.Automation.CompletionResult]::new($_.value, "$($_.value)$desc", 'ParameterValue', $_.value)
}
$env:XMAKE_SKIP_HISTORY = $oldenv
}
+
# PowerShell parameter completion for xrepo
Register-ArgumentCompleter -Native -CommandName xrepo -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
@@ -23,9 +29,14 @@ Register-ArgumentCompleter -Native -CommandName xrepo -ScriptBlock {
}
$oldenv = $env:XMAKE_SKIP_HISTORY
$env:XMAKE_SKIP_HISTORY = 1
- xmake lua "private.xrepo.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value | ForEach-Object {
+ $results = xmake lua "private.xrepo.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value
+ $results | ForEach-Object {
$hasdesc = [bool] $_.psobject.Properties['description']
- $desc = $hasdesc ? " - $($_.description)" : ""
+ if ($hasdesc) {
+ $desc = " - $($_.description)"
+ } else {
+ $desc = ""
+ }
[System.Management.Automation.CompletionResult]::new($_.value, "$($_.value)$desc", 'ParameterValue', $_.value)
}
$env:XMAKE_SKIP_HISTORY = $oldenv
diff --git a/xmake/scripts/profile-win.ps1 b/xmake/scripts/profile-win.ps1
index f19c48233..201f291cd 100644
--- a/xmake/scripts/profile-win.ps1
+++ b/xmake/scripts/profile-win.ps1
@@ -7,13 +7,19 @@ Register-ArgumentCompleter -Native -CommandName xmake -ScriptBlock {
}
$oldenv = $env:XMAKE_SKIP_HISTORY
$env:XMAKE_SKIP_HISTORY = 1
- xmake lua "private.utils.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value | ForEach-Object {
+ $results = xmake lua "private.utils.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value
+ $results | ForEach-Object {
$hasdesc = [bool] $_.psobject.Properties['description']
- $desc = $hasdesc ? " - $($_.description)" : ""
+ if ($hasdesc) {
+ $desc = " - $($_.description)"
+ } else {
+ $desc = ""
+ }
[System.Management.Automation.CompletionResult]::new($_.value, "$($_.value)$desc", 'ParameterValue', $_.value)
}
$env:XMAKE_SKIP_HISTORY = $oldenv
}
+
# PowerShell parameter completion for xrepo
Register-ArgumentCompleter -Native -CommandName xrepo -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
@@ -23,9 +29,14 @@ Register-ArgumentCompleter -Native -CommandName xrepo -ScriptBlock {
}
$oldenv = $env:XMAKE_SKIP_HISTORY
$env:XMAKE_SKIP_HISTORY = 1
- xmake lua "private.xrepo.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value | ForEach-Object {
+ $results = xmake lua "private.xrepo.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value
+ $results | ForEach-Object {
$hasdesc = [bool] $_.psobject.Properties['description']
- $desc = $hasdesc ? " - $($_.description)" : ""
+ if ($hasdesc) {
+ $desc = " - $($_.description)"
+ } else {
+ $desc = ""
+ }
[System.Management.Automation.CompletionResult]::new($_.value, "$($_.value)$desc", 'ParameterValue', $_.value)
}
$env:XMAKE_SKIP_HISTORY = $oldenv