aboutsummaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-07-28 14:41:35 +0200
committerGitHub <noreply@github.com>2020-07-28 14:41:35 +0200
commit51c887ff9dd4f2a5f65d2d3de57f8a7729b1010d (patch)
tree434b75cbe63543ba5f609dadfb0e891765d13ea8 /commands
parent0590de9f045c2090d72655a7c2e1d41be9b9104c (diff)
parenta62ce78c4fc4e541cecaab0ab22def8752d3d9e2 (diff)
downloadgit-bug-51c887ff9dd4f2a5f65d2d3de57f8a7729b1010d.tar.gz
Merge pull request #433 from MichaelMure/remove-bug-2
Add the 'rm' command
Diffstat (limited to 'commands')
-rw-r--r--commands/rm.go43
-rw-r--r--commands/root.go1
2 files changed, 44 insertions, 0 deletions
diff --git a/commands/rm.go b/commands/rm.go
new file mode 100644
index 00000000..09f6a6cc
--- /dev/null
+++ b/commands/rm.go
@@ -0,0 +1,43 @@
+package commands
+
+import (
+ "errors"
+
+ "github.com/spf13/cobra"
+)
+
+func newRmCommand() *cobra.Command {
+ env := newEnv()
+
+ cmd := &cobra.Command{
+ Use: "rm <id>",
+ Short: "Remove an existing bug.",
+ Long: "Remove an existing bug in the local repository. Note removing bugs that were imported from bridges will not remove the bug on the remote, and will only remove the local copy of the bug.",
+ PreRunE: loadBackendEnsureUser(env),
+ PostRunE: closeBackend(env),
+ RunE: func(cmd *cobra.Command, args []string) error {
+ return runRm(env, args)
+ },
+ }
+
+ flags := cmd.Flags()
+ flags.SortFlags = false
+
+ return cmd
+}
+
+func runRm(env *Env, args []string) (err error) {
+ if len(args) == 0 {
+ return errors.New("you must provide a bug prefix to remove")
+ }
+
+ err = env.backend.RemoveBug(args[0])
+
+ if err != nil {
+ return
+ }
+
+ env.out.Printf("bug %s removed\n", args[0])
+
+ return
+}
diff --git a/commands/root.go b/commands/root.go
index a67fec1a..e7848363 100644
--- a/commands/root.go
+++ b/commands/root.go
@@ -71,6 +71,7 @@ _git_bug() {
cmd.AddCommand(newLsLabelCommand())
cmd.AddCommand(newPullCommand())
cmd.AddCommand(newPushCommand())
+ cmd.AddCommand(newRmCommand())
cmd.AddCommand(newSelectCommand())
cmd.AddCommand(newShowCommand())
cmd.AddCommand(newStatusCommand())