summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorluna <[email protected]>2023-02-25 18:32:40 +0800
committerluna <[email protected]>2023-02-25 18:32:40 +0800
commitbdf4347f2a0f62e32a8c59a853297628e1b00220 (patch)
tree3a714e3824b9e7141b5f240d2b6f4b0446b97483 /scripts
parentd960f672350aa0a446c3a0f403c156cc207232b0 (diff)
Replace the ternary operator with the if/else statement
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/register-completions.ps119
1 files changed, 15 insertions, 4 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