Skip to content

Commit

Permalink
powershell: register with list
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Nov 8, 2024
1 parent 633eaba commit df49751
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 df49751

Please sign in to comment.