Skip to content

Commit f3883a0

Browse files
stainless-app[bot]batuhan
authored andcommitted
fix: avoid printing usage errors twice
1 parent 6afe4f9 commit f3883a0

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

cmd/beeper-desktop-cli/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ func main() {
4242
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
4343
}
4444
} else {
45-
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
45+
if cmd.CommandErrorBuffer.Len() > 0 {
46+
os.Stderr.Write(cmd.CommandErrorBuffer.Bytes())
47+
} else {
48+
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
49+
}
4650
}
4751
os.Exit(exitCode)
4852
}

pkg/cmd/cmd.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package cmd
44

55
import (
6+
"bytes"
67
"compress/gzip"
78
"context"
89
"fmt"
@@ -18,15 +19,17 @@ import (
1819
)
1920

2021
var (
21-
Command *cli.Command
22+
Command *cli.Command
23+
CommandErrorBuffer bytes.Buffer
2224
)
2325

2426
func init() {
2527
Command = &cli.Command{
26-
Name: "beeper-desktop-cli",
27-
Usage: "CLI for the beeperdesktop API",
28-
Suggest: true,
29-
Version: Version,
28+
Name: "beeper-desktop-cli",
29+
Usage: "CLI for the beeperdesktop API",
30+
Suggest: true,
31+
Version: Version,
32+
ErrWriter: &CommandErrorBuffer,
3033
Flags: []cli.Flag{
3134
&cli.BoolFlag{
3235
Name: "debug",

0 commit comments

Comments
 (0)