MCPcopy Create free account
hub / github.com/git-bug/git-bug / runBugShow

Function runBugShow

commands/bug/bug_show.go:49–110  ·  view source on GitHub ↗
(env *execenv.Env, opts bugShowOptions, args []string)

Source from the content-addressed store, hash-verified

47}
48
49func runBugShow(env *execenv.Env, opts bugShowOptions, args []string) error {
50 b, _, err := ResolveSelected(env.Backend, args)
51 if err != nil {
52 return err
53 }
54
55 snap := b.Snapshot()
56
57 if len(snap.Comments) == 0 {
58 return errors.New("invalid bug: no comment")
59 }
60
61 if opts.fields != "" {
62 switch opts.fields {
63 case "author":
64 env.Out.Printf("%s\n", snap.Author.DisplayName())
65 case "authorEmail":
66 env.Out.Printf("%s\n", snap.Author.Email())
67 case "createTime":
68 env.Out.Printf("%s\n", snap.CreateTime.String())
69 case "lastEdit":
70 env.Out.Printf("%s\n", snap.EditTime().String())
71 case "humanId":
72 env.Out.Printf("%s\n", snap.Id().Human())
73 case "id":
74 env.Out.Printf("%s\n", snap.Id())
75 case "labels":
76 for _, l := range snap.Labels {
77 env.Out.Printf("%s\n", l.String())
78 }
79 case "actors":
80 for _, a := range snap.Actors {
81 env.Out.Printf("%s\n", a.DisplayName())
82 }
83 case "participants":
84 for _, p := range snap.Participants {
85 env.Out.Printf("%s\n", p.DisplayName())
86 }
87 case "shortId":
88 env.Out.Printf("%s\n", snap.Id().Human())
89 case "status":
90 env.Out.Printf("%s\n", snap.Status)
91 case "title":
92 env.Out.Printf("%s\n", snap.Title)
93 default:
94 return fmt.Errorf("unsupported field: %s", opts.fields)
95 }
96
97 return nil
98 }
99
100 switch opts.format {
101 case "org-mode":
102 return showOrgModeFormatter(env, snap)
103 case "json":
104 return showJsonFormatter(env, snap)
105 case "default":
106 return showDefaultFormatter(env, snap)

Callers 1

newBugShowCommandFunction · 0.85

Calls 14

ResolveSelectedFunction · 0.85
showOrgModeFormatterFunction · 0.85
showJsonFormatterFunction · 0.85
showDefaultFormatterFunction · 0.85
SnapshotMethod · 0.80
ErrorfMethod · 0.80
PrintfMethod · 0.65
DisplayNameMethod · 0.65
EmailMethod · 0.65
StringMethod · 0.65
IdMethod · 0.65
NewMethod · 0.45

Tested by

no test coverage detected