1package commands
2
3import (
4 "errors"
5
6 "github.com/MichaelMure/git-bug/bug"
7 "github.com/MichaelMure/git-bug/bug/operations"
8 "github.com/spf13/cobra"
9)
10
11func runCloseBug(cmd *cobra.Command, args []string) error {
12 if len(args) > 1 {
13 return errors.New("Only closing one bug at a time is supported")
14 }
15
16 if len(args) == 0 {
17 return errors.New("You must provide a bug id")
18 }
19
20 prefix := args[0]
21
22 b, err := bug.FindLocalBug(repo, prefix)
23 if err != nil {
24 return err
25 }
26
27 author, err := bug.GetUser(repo)
28 if err != nil {
29 return err
30 }
31
32 operations.Close(b, author)
33
34 return b.Commit(repo)
35}
36
37var closeCmd = &cobra.Command{
38 Use: "close <id>",
39 Short: "Mark the bug as closed",
40 RunE: runCloseBug,
41}
42
43func init() {
44 RootCmd.AddCommand(closeCmd)
45}