Skip to content

Commit 5d58fd1

Browse files
committed
Use home dir function from config
user.Current() isn't implemented on all OS/architectures.
1 parent 854eb12 commit 5d58fd1

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

handlers/debug.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,37 @@ package handlers
33
import (
44
"fmt"
55
"log"
6-
"os/user"
76
"runtime"
87

98
"github.com/codegangsta/cli"
109
"github.com/exercism/cli/config"
1110
)
1211

1312
func Debug(ctx *cli.Context) {
14-
usr, err := user.Current()
15-
if err != nil {
16-
log.Fatal(err)
13+
bail := func(err error) {
14+
if err != nil {
15+
fmt.Printf("\nIf you are having any issues, please contact kytrinyx@exercism.io with this information.\n")
16+
log.Fatal(err)
17+
}
1718
}
1819

19-
fmt.Printf("Debug Information\n")
20+
fmt.Printf("\n**** Debug Information ****\n")
21+
fmt.Printf("Exercism CLI Version: %s\n", ctx.App.Version)
2022
fmt.Printf("OS/Architecture: %s/%s\n", runtime.GOOS, runtime.GOARCH)
21-
fmt.Printf("Home Dir: %s\n", usr.HomeDir)
22-
fmt.Printf("Version: %s\n", ctx.App.Version)
23+
24+
dir, err := config.Home()
25+
bail(err)
26+
fmt.Printf("Home Dir: %s\n", dir)
2327

2428
file, err := config.FilePath(ctx.GlobalString("config"))
25-
if err != nil {
26-
log.Fatal(err)
27-
}
29+
bail(err)
2830

2931
c, err := config.Read(file)
30-
if err == nil {
31-
fmt.Printf("\nExercism Configuration\n")
32-
fmt.Printf("API Key: %s\n", c.APIKey)
33-
fmt.Printf("Exercises Directory: %s\n", c.Dir)
34-
fmt.Printf("Config file: %s\n", c.File())
35-
fmt.Printf("API: %s\n", c.Hostname)
36-
}
32+
bail(err)
3733

38-
fmt.Printf("\nIf you are having any issues, please contact kytrinyx@exercism.io with this information.\n")
34+
fmt.Printf("Config file: %s\n", c.File())
35+
fmt.Printf("API: %s\n", c.Hostname)
36+
fmt.Printf("API Key: %s\n", c.APIKey)
37+
fmt.Printf("Exercises Directory: %s\n", c.Dir)
38+
fmt.Println()
3939
}

0 commit comments

Comments
 (0)