-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathdebug.go
More file actions
51 lines (43 loc) · 1.24 KB
/
debug.go
File metadata and controls
51 lines (43 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package cmd
import (
"fmt"
"log"
"os"
"runtime"
"github.com/codegangsta/cli"
"github.com/exercism/cli/config"
)
// Debug provides information about the user's environment and configuration.
func Debug(ctx *cli.Context) {
defer fmt.Printf("\nIf you are having trouble and need to file a GitHub issue (https://github.com/exercism/exercism.io/issues) please include this information (except your API key. Keep that private).\n")
fmt.Printf("\n**** Debug Information ****\n")
fmt.Printf("Exercism CLI Version: %s\n", ctx.App.Version)
fmt.Printf("OS/Architecture: %s/%s\n", runtime.GOOS, runtime.GOARCH)
dir, err := config.Home()
if err != nil {
log.Fatal(err)
}
fmt.Printf("Home Dir: %s\n", dir)
file, err := config.FilePath(ctx.GlobalString("config"))
configured := true
if _, err = os.Stat(file); err != nil {
if os.IsNotExist(err) {
configured = false
} else {
log.Fatal(err)
}
}
c, err := config.Read(file)
if err != nil {
log.Fatal(err)
}
if configured {
fmt.Printf("Config file: %s\n", c.File())
fmt.Printf("API Key: %s\n", c.APIKey)
} else {
fmt.Println("Config file: <not configured>")
fmt.Println("API Key: <not configured>")
}
fmt.Printf("API: %s\n", c.API)
fmt.Printf("Exercises Directory: %s\n", c.Dir)
}