Skip to content

Commit da2d55b

Browse files
committed
Add a guard to the unsubmit command.
The unsubmit command does not take any arguments, but it would be easy to assume that it does, considering how most of the other commands work. This changes the command so that it stops with a warning if someone tries to pass an argument. This change is in response to exercism/exercism#2446 where someone tried unsubmitting a submission by passing the file path to the unsubmit command, which blithely unsubmitted the most recent submission--period. It's confusing and unfriendly.
1 parent c802c91 commit da2d55b

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

cmd/unsubmit.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import (
99
"github.com/exercism/cli/config"
1010
)
1111

12-
// Unsubmit deletes an iteration from the api.
13-
// If no iteration is specified, the most recent iteration
14-
// is deleted.
12+
// Unsubmit deletes the most recent submission from the API.
1513
func Unsubmit(ctx *cli.Context) {
14+
if len(ctx.Args()) > 0 {
15+
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.")
16+
}
17+
1618
c, err := config.New(ctx.GlobalString("config"))
1719
if err != nil {
1820
log.Fatal(err)

exercism/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const (
2525
descRestore = "Restores completed and current problems on from exercism.io, along with your most recent iteration for each."
2626
descSubmit = "Submits a new iteration to a problem on exercism.io."
2727
descSkip = "Skips a problem given a language and slug."
28-
descUnsubmit = "Deletes the most recently submitted iteration."
28+
descUnsubmit = "Deletes the most recently submitted solution."
2929
descUpgrade = "Upgrades the CLI to the latest released version."
3030
descTracks = "List the available language tracks"
3131
descOpen = "Opens the current submission of the specified exercise"

0 commit comments

Comments
 (0)