diff --git a/handlers/debug.go b/handlers/debug.go new file mode 100644 index 000000000..ecb5b6977 --- /dev/null +++ b/handlers/debug.go @@ -0,0 +1,39 @@ +package handlers + +import ( + "fmt" + "log" + "os/user" + "runtime" + + "github.com/codegangsta/cli" + "github.com/exercism/cli/config" +) + +func Debug(ctx *cli.Context) { + usr, err := user.Current() + if err != nil { + log.Fatal(err) + } + + fmt.Printf("Debug Information\n") + fmt.Printf("OS/Architecture: %s/%s\n", runtime.GOOS, runtime.GOARCH) + fmt.Printf("Home Dir: %s\n", usr.HomeDir) + fmt.Printf("Version: %s\n", ctx.App.Version) + + file, err := config.FilePath(ctx.GlobalString("config")) + if err != nil { + log.Fatal(err) + } + + c, err := config.Read(file) + if err == nil { + fmt.Printf("\nExercism Configuration\n") + fmt.Printf("API Key: %s\n", c.APIKey) + fmt.Printf("Exercises Directory: %s\n", c.Dir) + fmt.Printf("Config file: %s\n", c.File()) + fmt.Printf("API: %s\n", c.Hostname) + } + + fmt.Printf("\nIf you are having any issues, please contact kytrinyx@exercism.io with this information.\n") +} diff --git a/main.go b/main.go index cad2318f0..beb33f750 100644 --- a/main.go +++ b/main.go @@ -59,6 +59,11 @@ func main() { }, } app.Commands = []cli.Command{ + { + Name: "debug", + Usage: "Outputs useful debug information.", + Action: handlers.Debug, + }, { Name: "configure", Usage: "Write config values to a JSON file",