package cmd
import (
"fmt"
"github.com/spf13/cobra"
cliErrors "gitlab.com/pcanilho/go-jira-cli/cmd/errors"
"gitlab.com/pcanilho/go-jira-cli/cmd/helpers"
)
var deleteCmd = &cobra.Command{
Use: "delete",
Short: "Deletes tickets/issues based on a provided ID or key",
Example: fmt.Sprintf("%s %s delete key1 key2 ... keyN", name, issueCmd.Name()),
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return fmt.Errorf("please specify the ticket key or ID to delete")
}
for _, issueID := range args {
issue, err := jiraController.GetIssue(issueID, nil)
if err != nil {
return fmt.Errorf("unable to find a ticket with the key [%s]", issueID)
}
if !skipPrompts {
cl := helpers.NewChangeLog()
cl.AddChange("Issue deletion", issue.Key, "", false, true)
fmt.Println(cl)
confirmed, _ := helpers.PromptToContinue()
if !confirmed {
helpers.ExitWithAbort()
}
}
if err = jiraController.DeleteIssue(issueID); err != nil {
return cliErrors.NewCliError(err)
}
fmt.Printf("Deleted [%s]\n", issueID)
}
return nil
},
}
|
The pages are generated with Golds v0.3.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |