Skip to content

Commit

Permalink
Merge pull request #1053 from carapace-sh/powershell-list
Browse files Browse the repository at this point in the history
powershell: register with list
  • Loading branch information
rsteube authored Nov 8, 2024
2 parents 633eaba + df49751 commit f887f2a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions example/cmd/_test/powershell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'

6 changes: 2 additions & 4 deletions internal/shell/powershell/snippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
}
Expand All @@ -71,6 +70,5 @@ func Snippet(cmd *cobra.Command) string {
cmd.Name(),
cmd.Name(),
prefix,
cmd.Name(),
cmd.Name())
}

0 comments on commit f887f2a

Please sign in to comment.