-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathunsubmit.go
More file actions
33 lines (26 loc) · 760 Bytes
/
unsubmit.go
File metadata and controls
33 lines (26 loc) · 760 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
package cmd
import (
"fmt"
"log"
"github.com/codegangsta/cli"
"github.com/exercism/cli/api"
"github.com/exercism/cli/config"
)
// Unsubmit deletes the most recent submission from the API.
func Unsubmit(ctx *cli.Context) {
if len(ctx.Args()) > 0 {
log.Fatal("\nThe unsubmit command does not take any arguments, it deletes the most recent submission.\n\nTo delete a different submission, you'll need to do it from the website.")
}
c, err := config.New(ctx.GlobalString("config"))
if err != nil {
log.Fatal(err)
}
if !c.IsAuthenticated() {
log.Fatal(msgPleaseAuthenticate)
}
client := api.NewClient(c)
if err := client.Unsubmit(); err != nil {
log.Fatal(err)
}
fmt.Println("Your most recent submission was successfully deleted.")
}