bug_status_close.go

 1package bugcmd
 2
 3import (
 4	"github.com/spf13/cobra"
 5
 6	"github.com/MichaelMure/git-bug/commands/execenv"
 7)
 8
 9func newBugStatusCloseCommand(env *execenv.Env) *cobra.Command {
10	cmd := &cobra.Command{
11		Use:     "close [BUG_ID]",
12		Short:   "Mark a bug as closed",
13		PreRunE: execenv.LoadBackendEnsureUser(env),
14		RunE: execenv.CloseBackend(env, func(cmd *cobra.Command, args []string) error {
15			return runBugStatusClose(env, args)
16		}),
17		ValidArgsFunction: BugCompletion(env),
18	}
19
20	return cmd
21}
22
23func runBugStatusClose(env *execenv.Env, args []string) error {
24	b, args, err := ResolveSelected(env.Backend, args)
25	if err != nil {
26		return err
27	}
28
29	_, err = b.Close()
30	if err != nil {
31		return err
32	}
33
34	return b.Commit()
35}