git-bug/commands/status_open.go

49 lines
759 B
Go
Raw Normal View History

2018-07-17 20:28:37 +03:00
package commands
import (
"errors"
2018-08-13 19:32:11 +03:00
"github.com/MichaelMure/git-bug/cache"
"github.com/spf13/cobra"
2018-07-17 20:28:37 +03:00
)
func runStatusOpen(cmd *cobra.Command, args []string) error {
2018-07-17 20:28:37 +03:00
if len(args) > 1 {
return errors.New("Only opening one bug at a time is supported")
}
if len(args) == 0 {
return errors.New("You must provide a bug id")
}
backend, err := cache.NewRepoCache(repo)
if err != nil {
return err
}
defer backend.Close()
2018-07-17 20:28:37 +03:00
prefix := args[0]
b, err := backend.ResolveBugPrefix(prefix)
2018-07-17 20:28:37 +03:00
if err != nil {
return err
}
err = b.Open()
if err != nil {
return err
}
return b.Commit()
2018-07-17 20:28:37 +03:00
}
var openCmd = &cobra.Command{
Use: "open <id>",
Short: "Mark the bug as open",
RunE: runStatusOpen,
}
func init() {
statusCmd.AddCommand(openCmd)
2018-07-17 20:28:37 +03:00
}