-
Notifications
You must be signed in to change notification settings - Fork 86
Set stdout so CLI completion feature works correctly #2262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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" | ||
|
|
@@ -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 { | ||
| rootCmd.SetOut(os.Stderr) | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| return rootCmd | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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)