Skip to content

Commit 854eb12

Browse files
committed
Merge pull request #100 from Tonkpils/debug-command
Added a debug command
2 parents 27e8065 + 304efd7 commit 854eb12

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

handlers/debug.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package handlers
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"os/user"
7+
"runtime"
8+
9+
"github.com/codegangsta/cli"
10+
"github.com/exercism/cli/config"
11+
)
12+
13+
func Debug(ctx *cli.Context) {
14+
usr, err := user.Current()
15+
if err != nil {
16+
log.Fatal(err)
17+
}
18+
19+
fmt.Printf("Debug Information\n")
20+
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+
file, err := config.FilePath(ctx.GlobalString("config"))
25+
if err != nil {
26+
log.Fatal(err)
27+
}
28+
29+
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+
}
37+
38+
fmt.Printf("\nIf you are having any issues, please contact kytrinyx@exercism.io with this information.\n")
39+
}

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ func main() {
5959
},
6060
}
6161
app.Commands = []cli.Command{
62+
{
63+
Name: "debug",
64+
Usage: "Outputs useful debug information.",
65+
Action: handlers.Debug,
66+
},
6267
{
6368
Name: "configure",
6469
Usage: "Write config values to a JSON file",

0 commit comments

Comments
 (0)