Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions internal/cmd/skupper/root/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package root

import (
"os"
"slices"

"github.com/skupperproject/skupper/internal/cmd/skupper/common"
"github.com/skupperproject/skupper/internal/cmd/skupper/connector"
"github.com/skupperproject/skupper/internal/cmd/skupper/debug"
Expand Down Expand Up @@ -38,6 +41,11 @@ func NewSkupperRootCommand() *cobra.Command {

rootCmd.SetHelpCommand(&cobra.Command{Hidden: true})

completionCommands := []string{"completion", cobra.ShellCompRequestCmd, cobra.ShellCompNoDescRequestCmd}
if slices.Contains(completionCommands, os.Args[1]) && len(os.Args) <= 2 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will panic if no arguments are given (there's no os.Args[1], then)

rootCmd.SetOut(os.Stderr)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my education, could you explain what is going on here? I'm not sure I follow the logic of setting the command output stream to stderr except for completion commands.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is to fix the issue that Danilo found with completion command.
skupper completion subcommand throws errors into stdout #2135


return rootCmd
}

Expand Down