-
-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
user.Current() isn't implemented on all OS/architectures.
- Loading branch information
Showing
1 changed file
with
18 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
} |