summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorruki <[email protected]>2022-12-29 22:02:32 +0800
committerGitHub <[email protected]>2022-12-29 22:02:32 +0800
commit784ffcfa42c47554cc469f9a007eb39cd92e8f2d (patch)
treed19476cf9927e986d8ccb8b43b514f14d949945e /scripts
parentda9f602edda385b219c6982658533ac9dc41af2a (diff)
parentd83a30682c8dd71819416f967b43ec10ebae59f5 (diff)
Merge pull request #3226 from glcraft/dev
Add description in powershell completion
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/register-completions.ps118
1 files changed, 11 insertions, 7 deletions
diff --git a/scripts/register-completions.ps1 b/scripts/register-completions.ps1
index e54e38c16..f19c48233 100755
--- a/scripts/register-completions.ps1
+++ b/scripts/register-completions.ps1
@@ -1,5 +1,4 @@
-# PowerShell parameter completion shim for xmake
-
+# PowerShell parameter completion for xmake
Register-ArgumentCompleter -Native -CommandName xmake -ScriptBlock {
param($commandName, $wordToComplete, $cursorPosition)
$complete = "$wordToComplete"
@@ -8,11 +7,14 @@ Register-ArgumentCompleter -Native -CommandName xmake -ScriptBlock {
}
$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', $_)
+ xmake lua "private.utils.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value | ForEach-Object {
+ $hasdesc = [bool] $_.psobject.Properties['description']
+ $desc = $hasdesc ? " - $($_.description)" : ""
+ [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)
$complete = "$wordToComplete"
@@ -21,8 +23,10 @@ Register-ArgumentCompleter -Native -CommandName xrepo -ScriptBlock {
}
$oldenv = $env:XMAKE_SKIP_HISTORY
$env:XMAKE_SKIP_HISTORY = 1
- xmake lua --root private.xrepo.complete "0" "nospace" "$complete" | ForEach-Object {
- [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
+ xmake lua "private.xrepo.complete" $cursorPosition "nospace-json" "$complete" | ConvertFrom-Json | Sort-Object -Property value | ForEach-Object {
+ $hasdesc = [bool] $_.psobject.Properties['description']
+ $desc = $hasdesc ? " - $($_.description)" : ""
+ [System.Management.Automation.CompletionResult]::new($_.value, "$($_.value)$desc", 'ParameterValue', $_.value)
}
$env:XMAKE_SKIP_HISTORY = $oldenv
-}
+} \ No newline at end of file