Skip to content

Commit 02b8bbd

Browse files
feat(client): print error messages to stderr
1 parent 3a287ac commit 02b8bbd

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

client/cmd/auth.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"fmt"
66
"net/url"
7+
"os"
78
"strings"
89
"syscall"
910

@@ -72,7 +73,7 @@ func Register(controller string, username string, password string, email string,
7273
c.Token = ""
7374

7475
if err != nil {
75-
fmt.Print("Registration failed: ")
76+
fmt.Fprint(os.Stderr, "Registration failed: ")
7677
return err
7778
}
7879

@@ -187,7 +188,7 @@ func Passwd(username string, password string, newPassword string) error {
187188
err = auth.Passwd(c, username, password, newPassword)
188189

189190
if err != nil {
190-
fmt.Print("Password change failed: ")
191+
fmt.Fprint(os.Stderr, "Password change failed: ")
191192
return err
192193
}
193194

@@ -235,7 +236,7 @@ func Cancel(username string, password string, yes bool) error {
235236
}
236237

237238
if yes == false {
238-
fmt.Println("Account not changed")
239+
fmt.Fprintln(os.Stderr, "Account not changed")
239240
return nil
240241
}
241242

client/deis.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ Use 'git push deis master' to deploy to an application.
6767
_, err := docopt.Parse(usage, []string{command}, false, version.Version, true, false)
6868

6969
if err != nil {
70-
fmt.Println(err)
70+
fmt.Fprintln(os.Stderr, err)
7171
return 1
7272
}
7373

7474
if len(argv) == 0 {
75-
fmt.Println("Usage: deis <command> [<args>...]")
75+
fmt.Fprintf(os.Stderr, "Usage: deis <command> [<args>...]")
7676
return 1
7777
}
7878

@@ -139,7 +139,7 @@ Use 'git push deis master' to deploy to an application.
139139
}
140140
}
141141
if err != nil {
142-
fmt.Printf("Error: %v\n", err)
142+
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
143143
return 1
144144
}
145145
return 0

client/parser/utils.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package parser
22

33
import (
44
"fmt"
5+
"os"
56
"strconv"
67
)
78

@@ -22,8 +23,8 @@ func responseLimit(limit string) (int, error) {
2223

2324
// PrintUsage runs if no matching command is found.
2425
func PrintUsage() {
25-
fmt.Println("Found no matching command, try 'deis help'")
26-
fmt.Println("Usage: deis <command> [<args>...]")
26+
fmt.Fprintln(os.Stderr, "Found no matching command, try 'deis help'")
27+
fmt.Fprintln(os.Stderr, "Usage: deis <command> [<args>...]")
2728
}
2829

2930
func printHelp(argv []string, usage string) bool {

0 commit comments

Comments
 (0)