bug_status_open.go

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