-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathdemo.go
More file actions
40 lines (31 loc) · 778 Bytes
/
demo.go
File metadata and controls
40 lines (31 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package cmd
import (
"fmt"
"log"
"github.com/codegangsta/cli"
"github.com/exercism/cli/api"
"github.com/exercism/cli/config"
"github.com/exercism/cli/user"
)
// Demo returns one problem for each active track.
func Demo(ctx *cli.Context) {
c, err := config.New(ctx.GlobalString("config"))
if err != nil {
log.Fatal(err)
}
client := api.NewClient(c)
problems, err := client.Demo()
if err != nil {
log.Fatal(err)
}
if dirOpt := ctx.String("dir"); dirOpt != "" {
c.SetDir(dirOpt)
}
fmt.Printf("Your exercises will be saved at: %s\n", c.Dir)
hw := user.NewHomework(problems, c)
if err := hw.Save(); err != nil {
log.Fatal(err)
}
hw.Report(user.HWAll)
fmt.Println("Next step: choose a language, read the README, and make the test suite pass.")
}