From dcd299e45983223afefaa8363179217d4c660654 Mon Sep 17 00:00:00 2001 From: gly Date: Thu, 29 Dec 2022 13:25:08 +0100 Subject: Add description in powershell completion --- scripts/register-completions.ps1 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/register-completions.ps1 b/scripts/register-completions.ps1 index e54e38c16..7ec3f29d3 100755 --- a/scripts/register-completions.ps1 +++ b/scripts/register-completions.ps1 @@ -8,8 +8,10 @@ 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 } @@ -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 -- cgit v1.3.1 From d83a30682c8dd71819416f967b43ec10ebae59f5 Mon Sep 17 00:00:00 2001 From: gly Date: Thu, 29 Dec 2022 14:03:43 +0100 Subject: Add powershell comments --- scripts/register-completions.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/register-completions.ps1 b/scripts/register-completions.ps1 index 7ec3f29d3..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" @@ -15,6 +14,7 @@ Register-ArgumentCompleter -Native -CommandName xmake -ScriptBlock { } $env:XMAKE_SKIP_HISTORY = $oldenv } +# PowerShell parameter completion for xrepo Register-ArgumentCompleter -Native -CommandName xrepo -ScriptBlock { param($commandName, $wordToComplete, $cursorPosition) $complete = "$wordToComplete" -- cgit v1.3.1