(env *execenv.Env, opts bugShowOptions, args []string)
| 47 | } |
| 48 | |
| 49 | func 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) |
no test coverage detected