Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions handlers/debug.go
Original file line number Diff line number Diff line change
@@ -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")
}
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down