Fix logic error in #1532 (#1564)

## Changes

This snuck into #1532 right before merging. The result is that error
output is no longer logged. This includes actual execution errors as
well as help output if arguments or flags are incorrectly specified.

We don't have test coverage for the `root.Execute` function. This is to
be fixed later.

## Tests

Manually confirmed we observe error output again.
This commit is contained in:
Pieter Noordhuis 2024-07-03 18:23:19 +02:00 committed by GitHub
parent 2a73d7788b
commit 7d2aa35738
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -98,7 +98,7 @@ func Execute(cmd *cobra.Command) {
// Run the command // Run the command
cmd, err := cmd.ExecuteContextC(ctx) cmd, err := cmd.ExecuteContextC(ctx)
if err != nil && errors.Is(err, ErrAlreadyPrinted) { if err != nil && !errors.Is(err, ErrAlreadyPrinted) {
// If cmdio logger initialization succeeds, then this function logs with the // If cmdio logger initialization succeeds, then this function logs with the
// initialized cmdio logger, otherwise with the default cmdio logger // initialized cmdio logger, otherwise with the default cmdio logger
cmdio.LogError(cmd.Context(), err) cmdio.LogError(cmd.Context(), err)