Skip to content

Commit

Permalink
Use home dir function from config
Browse files Browse the repository at this point in the history
user.Current() isn't implemented on all OS/architectures.
  • Loading branch information
kytrinyx committed Aug 28, 2014
1 parent 854eb12 commit 5d58fd1
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions handlers/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@ 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)
bail := func(err error) {
if err != nil {
fmt.Printf("\nIf you are having any issues, please contact [email protected] with this information.\n")
log.Fatal(err)
}
}

fmt.Printf("Debug Information\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)
fmt.Printf("Home Dir: %s\n", usr.HomeDir)
fmt.Printf("Version: %s\n", ctx.App.Version)

dir, err := config.Home()
bail(err)
fmt.Printf("Home Dir: %s\n", dir)

file, err := config.FilePath(ctx.GlobalString("config"))
if err != nil {
log.Fatal(err)
}
bail(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)
}
bail(err)

fmt.Printf("\nIf you are having any issues, please contact [email protected] with this information.\n")
fmt.Printf("Config file: %s\n", c.File())
fmt.Printf("API: %s\n", c.Hostname)
fmt.Printf("API Key: %s\n", c.APIKey)
fmt.Printf("Exercises Directory: %s\n", c.Dir)
fmt.Println()
}

0 comments on commit 5d58fd1

Please sign in to comment.