-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathrestore.go
More file actions
32 lines (26 loc) · 588 Bytes
/
restore.go
File metadata and controls
32 lines (26 loc) · 588 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
package cmd
import (
"fmt"
"log"
"github.com/codegangsta/cli"
"github.com/exercism/cli/api"
"github.com/exercism/cli/config"
"github.com/exercism/cli/user"
)
// Restore returns a user's solved problems.
func Restore(ctx *cli.Context) {
c, err := config.Read(ctx.GlobalString("config"))
if err != nil {
log.Fatal(err)
}
url := fmt.Sprintf("%s/api/v1/iterations/%s/restore", c.API, c.APIKey)
problems, err := api.Fetch(url)
if err != nil {
log.Fatal(err)
}
hw := user.NewHomework(problems, c)
if err := hw.Save(); err != nil {
log.Fatal(err)
}
hw.Summarize()
}