Skip to content

Commit 2b77105

Browse files
authored
[stderr] Fix a few prints that were going to out instead of err DEV-1282 (#674)
## Summary This changes output for * add * global add * global pull (since these are not expected to print anything except diagnostic output) It also fixes the debug middleware which prints all errors. ## How was it tested? `devbox run test`
1 parent 2f25b12 commit 2b77105

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

internal/boxcli/add.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func AddCmd() *cobra.Command {
2929
RunE: func(cmd *cobra.Command, args []string) error {
3030
if len(args) == 0 {
3131
fmt.Fprintf(
32-
cmd.OutOrStdout(),
32+
cmd.ErrOrStderr(),
3333
"Usage: %s\n\n%s\n",
3434
cmd.UseLine(),
3535
toSearchForPackages,

internal/boxcli/global.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func globalAddCmd() *cobra.Command {
3838
RunE: func(cmd *cobra.Command, args []string) error {
3939
if len(args) == 0 {
4040
fmt.Fprintf(
41-
cmd.OutOrStdout(),
41+
cmd.ErrOrStderr(),
4242
"Usage: %s\n\n%s\n",
4343
cmd.UseLine(),
4444
toSearchForPackages,
@@ -65,7 +65,7 @@ func globalRemoveCmd() *cobra.Command {
6565
RunE: func(cmd *cobra.Command, args []string) error {
6666
if len(args) == 0 {
6767
fmt.Fprintf(
68-
cmd.OutOrStdout(),
68+
cmd.ErrOrStderr(),
6969
"Usage: %s\n\n%s\n",
7070
cmd.UseLine(),
7171
toSearchForPackages,
@@ -165,7 +165,7 @@ func pullGlobalCmdFunc(cmd *cobra.Command, args []string) error {
165165
if _, err := devbox.InitConfig(path, cmd.ErrOrStderr()); err != nil {
166166
return errors.WithStack(err)
167167
}
168-
box, err := devbox.Open(path, cmd.OutOrStdout())
168+
box, err := devbox.Open(path, cmd.ErrOrStderr())
169169
if err != nil {
170170
return errors.WithStack(err)
171171
}

internal/boxcli/midcobra/debug.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ func (d *DebugMiddleware) postRun(cmd *cobra.Command, args []string, runErr erro
5757
if usererr.IsWarning(runErr) {
5858
ux.Fwarning(cmd.ErrOrStderr(), runErr.Error())
5959
} else {
60-
color.Red("\nError: " + runErr.Error() + "\n\n")
60+
color.New(color.FgRed).Fprintf(cmd.ErrOrStderr(), "\nError: %s\n\n", runErr.Error())
6161
}
6262
} else {
63-
fmt.Printf("Error: %v\n", runErr)
63+
fmt.Fprintf(cmd.ErrOrStderr(), "Error: %v\n", runErr)
6464
}
6565

6666
st := debug.EarliestStackTrace(runErr)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Do not support shell inception
22
exec devbox init
33
! exec devbox run devbox shell
4-
stdout 'Error: You are already in an active devbox shell.'
4+
stderr 'Error: You are already in an active devbox shell.'

0 commit comments

Comments
 (0)