rm.go

 1package commands
 2
 3import (
 4	"github.com/spf13/cobra"
 5)
 6
 7func newRmCommand() *cobra.Command {
 8	env := newEnv()
 9
10	cmd := &cobra.Command{
11		Use:      "rm <id> [<remote>]",
12		Short:    "Remove an existing bug.",
13		Long:     "Remove an existing bug in the local repository. If the bug was imported from a bridge, specify the remote name to remove it from. Note removing bugs that were imported from bridges will not remove the bug remote, and will only remove the local copy of the bug.",
14		PreRunE:  loadBackendEnsureUser(env),
15		PostRunE: closeBackend(env),
16		RunE: func(cmd *cobra.Command, args []string) error {
17			return runRm(env, args)
18		},
19	}
20
21	flags := cmd.Flags()
22	flags.SortFlags = false
23
24	return cmd
25}
26
27func runRm(env *Env, args []string) (err error) {
28	err = env.backend.RemoveBug(args)
29
30	if err != nil {
31		return
32	}
33
34	env.out.Printf("bug %s removed\n", args[0])
35
36	return
37}