From df4975177fa501fd31577db372e56387c7386b93 Mon Sep 17 00:00:00 2001 From: rsteube Date: Fri, 8 Nov 2024 22:51:56 +0100 Subject: [PATCH] powershell: register with list --- example/cmd/_test/powershell.ps1 | 3 +-- internal/shell/powershell/snippet.go | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/example/cmd/_test/powershell.ps1 b/example/cmd/_test/powershell.ps1 index a4e779560..f72b5c773 100644 --- a/example/cmd/_test/powershell.ps1 +++ b/example/cmd/_test/powershell.ps1 @@ -42,6 +42,5 @@ Function _example_completer { $completions } -Register-ArgumentCompleter -Native -CommandName 'example' -ScriptBlock (Get-Item "Function:_example_completer").ScriptBlock -# Register-ArgumentCompleter -Native -CommandName 'example.exe' -ScriptBlock (Get-Item "Function:_example_completer").ScriptBlock +Register-ArgumentCompleter -Native -ScriptBlock (Get-Item "Function:_example_completer").ScriptBlock -CommandName 'example' # ,'example.exe' diff --git a/internal/shell/powershell/snippet.go b/internal/shell/powershell/snippet.go index 37171dbe1..5c62cac4a 100644 --- a/internal/shell/powershell/snippet.go +++ b/internal/shell/powershell/snippet.go @@ -54,13 +54,12 @@ Function _%v_completer { $completions } -Register-ArgumentCompleter -Native -CommandName '%v' -ScriptBlock (Get-Item "Function:_%v_completer").ScriptBlock -%vRegister-ArgumentCompleter -Native -CommandName '%v.exe' -ScriptBlock (Get-Item "Function:_%v_completer").ScriptBlock +Register-ArgumentCompleter -Native -ScriptBlock (Get-Item "Function:_%v_completer").ScriptBlock -CommandName '%v'%v,'%v.exe' ` // Snippet creates the powershell completion script. func Snippet(cmd *cobra.Command) string { - prefix := "# " + prefix := " # " if runtime.GOOS == "windows" { prefix = "" } @@ -71,6 +70,5 @@ func Snippet(cmd *cobra.Command) string { cmd.Name(), cmd.Name(), prefix, - cmd.Name(), cmd.Name()) }