Don't error on list commands when no results found (#5479)
Co-authored-by: Mislav Marohnić <mislav@github.com>
This commit is contained in:
parent
adc9abd5ee
commit
13342cb272
33 changed files with 178 additions and 201 deletions
|
|
@ -203,6 +203,7 @@ func mainRun() exitCode {
|
|||
|
||||
if cmd, err := rootCmd.ExecuteC(); err != nil {
|
||||
var pagerPipeError *iostreams.ErrClosedPagerPipe
|
||||
var noResultsError cmdutil.NoResultsError
|
||||
if err == cmdutil.SilentError {
|
||||
return exitError
|
||||
} else if cmdutil.IsUserCancellation(err) {
|
||||
|
|
@ -216,6 +217,12 @@ func mainRun() exitCode {
|
|||
} else if errors.As(err, &pagerPipeError) {
|
||||
// ignore the error raised when piping to a closed pager
|
||||
return exitOK
|
||||
} else if errors.As(err, &noResultsError) {
|
||||
if cmdFactory.IOStreams.IsStdoutTTY() {
|
||||
fmt.Fprintln(stderr, noResultsError.Error())
|
||||
}
|
||||
// no results is not a command failure
|
||||
return exitOK
|
||||
}
|
||||
|
||||
printError(stderr, err, cmd, hasDebug)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue