Skip to content

Commit 0ccc7a4

Browse files
committed
Add debug output to submit command
1 parent 55fedd3 commit 0ccc7a4

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

cmd/submit.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"io/ioutil"
66
"log"
7+
"os"
78
"path/filepath"
89

910
"github.com/codegangsta/cli"
@@ -22,12 +23,26 @@ func Submit(ctx *cli.Context) {
2223
log.Fatal(err)
2324
}
2425

26+
if ctx.GlobalBool("debug") {
27+
log.Printf("Exercises dir: %s", c.Dir)
28+
dir, err := os.Getwd()
29+
if err != nil {
30+
log.Printf("Unable to get current working directory - %s", err)
31+
} else {
32+
log.Printf("Current dir: %s", dir)
33+
}
34+
}
35+
2536
if !c.IsAuthenticated() {
2637
log.Fatal(msgPleaseAuthenticate)
2738
}
2839

2940
filename := ctx.Args()[0]
3041

42+
if ctx.GlobalBool("debug") {
43+
log.Printf("file name: %s", filename)
44+
}
45+
3146
if isTest(filename) {
3247
log.Fatal("Please submit the solution, not the test file.")
3348
}
@@ -36,16 +51,29 @@ func Submit(ctx *cli.Context) {
3651
if err != nil {
3752
log.Fatal(err)
3853
}
54+
55+
if ctx.GlobalBool("debug") {
56+
log.Printf("absolute path: %s", file)
57+
}
58+
3959
file, err = filepath.EvalSymlinks(file)
4060
if err != nil {
4161
log.Fatal(err)
4262
}
4363

64+
if ctx.GlobalBool("debug") {
65+
log.Printf("eval symlinks (file): %s", file)
66+
}
67+
4468
dir, err := filepath.EvalSymlinks(c.Dir)
4569
if err != nil {
4670
log.Fatal(err)
4771
}
4872

73+
if ctx.GlobalBool("debug") {
74+
log.Printf("eval symlinks (dir): %s", dir)
75+
}
76+
4977
code, err := ioutil.ReadFile(file)
5078
if err != nil {
5179
log.Fatalf("Cannot read the contents of %s - %s\n", filename, err)

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ func main() {
4444
Name: "config, c",
4545
Usage: "path to config file",
4646
},
47+
cli.BoolFlag{
48+
Name: "debug, d",
49+
Usage: "turn on verbose logging",
50+
},
4751
}
4852
app.Commands = []cli.Command{
4953
{

0 commit comments

Comments
 (0)