-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathunsubmit.go
More file actions
30 lines (25 loc) · 654 Bytes
/
unsubmit.go
File metadata and controls
30 lines (25 loc) · 654 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
package cmd
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)
if err := api.Unsubmit(url); err != nil {
log.Fatal(err)
}
fmt.Println("Your most recent submission was successfully deleted.")
}