Make completion work again
@@ -78,8 +78,11 @@ func NewSkaffoldCommand(out, errOut io.Writer) *cobra.Command {
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
cmd.Root().SilenceUsage = true
- opts.Command = cmd.Use
- instrumentation.SetCommand(cmd.Use)
+ opts.Command = cmd.Name()
+ // Don't redirect output for Cobra internal `__complete` and `__completeNoDesc` commands.
+ // These are used for command completion and send debug messages on stderr.
+ if cmd.Name() != cobra.ShellCompRequestCmd && cmd.Name() != cobra.ShellCompNoDescRequestCmd {
+ instrumentation.SetCommand(cmd.Name())
out := output.GetWriter(out, defaultColor, forceColors)
if timestamps {
l := logrus.New()
@@ -95,6 +98,7 @@ func NewSkaffoldCommand(out, errOut io.Writer) *cobra.Command {
if err := setUpLogs(errOut, v, timestamps); err != nil {
return err
}
+ }
// Setup kubeContext and kubeConfig
kubectx.ConfigureKubeConfig(opts.KubeConfig, opts.KubeContext)
