mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-14 17:51:44 +03:00
bc6ba02bd8
Complete bug IDs, bridges, users, labels where appropriate. This works in bash and fish. ZSH is not yet supported by Cobra. In fish, descriptions (the part of a completion after the "\t") are shown as completion label, and can be searched with Ctrl+S. Reproduce with fish -C 'source misc/fish_completion/git-bug' git bug select ^I (tested with fish version 3.3.1) Also works with bash, but only for "git-bug" (with the dash) bash --rcfile <(echo source misc/bash_completion/git-bug) git-bug select ^I Closes #493
44 lines
919 B
Go
44 lines
919 B
Go
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),
|
|
RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error {
|
|
return runRm(env, args)
|
|
}),
|
|
ValidArgsFunction: completeBug(env),
|
|
}
|
|
|
|
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
|
|
}
|