[#1041] autocomplete: fetch output stream from provided command

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-01-11 15:43:24 +03:00 committed by Alex Vanin
parent c01acba3ce
commit c35cdb3684

View file

@ -2,7 +2,6 @@ package autocomplete
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
@ -48,13 +47,13 @@ func Command(name string) *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {
switch args[0] {
case "bash":
_ = cmd.Root().GenBashCompletion(os.Stdout)
_ = cmd.Root().GenBashCompletion(cmd.OutOrStdout())
case "zsh":
_ = cmd.Root().GenZshCompletion(os.Stdout)
_ = cmd.Root().GenZshCompletion(cmd.OutOrStdout())
case "fish":
_ = cmd.Root().GenFishCompletion(os.Stdout, true)
_ = cmd.Root().GenFishCompletion(cmd.OutOrStdout(), true)
case "powershell":
_ = cmd.Root().GenPowerShellCompletion(os.Stdout)
_ = cmd.Root().GenPowerShellCompletion(cmd.OutOrStdout())
}
},
}