File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ const VERSION = "1.3.2"
1414var FetchEndpoints = map [string ]string {
1515 "current" : "/api/v1/user/assignments/current" ,
1616 "next" : "/api/v1/user/assignments/next" ,
17+ "restore" : "/api/v1/user/assignments/restore" ,
1718 "demo" : "/api/v1/assignments/demo" ,
1819 "exercise" : "/api/v1/assignments" ,
1920}
Original file line number Diff line number Diff line change @@ -148,6 +148,33 @@ func main() {
148148 }
149149 },
150150 },
151+ {
152+ Name : "restore" ,
153+ ShortName : "r" ,
154+ Usage : "Restore completed and current assignments from exercism.io" ,
155+ Action : func (c * cli.Context ) {
156+ config , err := configuration .FromFile (configuration .HomeDir ())
157+ if err != nil {
158+ fmt .Println ("Are you sure you are logged in? Please login again." )
159+ return
160+ }
161+
162+ assignments , err := FetchAssignments (config , FetchEndpoints ["restore" ])
163+ if err != nil {
164+ fmt .Println (err )
165+ return
166+ }
167+
168+ for _ , a := range assignments {
169+ err := SaveAssignment (config .ExercismDirectory , a )
170+ if err != nil {
171+ fmt .Println (err )
172+ }
173+ }
174+
175+ fmt .Printf ("Exercises written to %s\n " , config .ExercismDirectory )
176+ },
177+ },
151178 {
152179 Name : "submit" ,
153180 ShortName : "s" ,
You can’t perform that action at this time.
0 commit comments