-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathunsubmit.go
More file actions
31 lines (26 loc) · 658 Bytes
/
unsubmit.go
File metadata and controls
31 lines (26 loc) · 658 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
package handlers
import (
"fmt"
"log"
"github.com/codegangsta/cli"
"github.com/exercism/cli/api"
"github.com/exercism/cli/config"
)
// Unsubmit deletes an iteration from the api.
// If no iteration is specified, the most recent iteration
// is deleted.
func Unsubmit(ctx *cli.Context) {
c, err := config.Read(ctx.GlobalString("config"))
if err != nil {
log.Fatal(err)
}
if !c.IsAuthenticated() {
log.Fatal(msgPleaseAuthenticate)
}
url := fmt.Sprintf("%s/api/v1/user/assignments?key=%s", c.API, c.APIKey)
err = api.Unsubmit(url)
if err != nil {
log.Fatal(err)
}
fmt.Println("Your most recent submission was successfully deleted.")
}