1package commands
2
3import (
4 "fmt"
5
6 "github.com/MichaelMure/git-bug/cache"
7 "github.com/MichaelMure/git-bug/commands/select"
8 "github.com/MichaelMure/git-bug/util/interrupt"
9 "github.com/spf13/cobra"
10)
11
12func runTitle(cmd *cobra.Command, args []string) error {
13 backend, err := cache.NewRepoCache(repo)
14 if err != nil {
15 return err
16 }
17 defer backend.Close()
18 interrupt.RegisterCleaner(backend.Close)
19
20 b, args, err := _select.ResolveBug(backend, args)
21 if err != nil {
22 return err
23 }
24
25 snap := b.Snapshot()
26
27 fmt.Println(snap.Title)
28
29 return nil
30}
31
32var titleCmd = &cobra.Command{
33 Use: "title [<id>]",
34 Short: "Display or change a title.",
35 PreRunE: loadRepo,
36 RunE: runTitle,
37}
38
39func init() {
40 RootCmd.AddCommand(titleCmd)
41
42 titleCmd.Flags().SortFlags = false
43}