| 95 | } |
| 96 | |
| 97 | func viewRun(opts *ViewOptions) error { |
| 98 | httpClient, err := opts.HttpClient() |
| 99 | if err != nil { |
| 100 | return err |
| 101 | } |
| 102 | |
| 103 | baseRepo, err := opts.BaseRepo() |
| 104 | if err != nil { |
| 105 | return err |
| 106 | } |
| 107 | |
| 108 | lookupFields := set.NewStringSet() |
| 109 | if opts.Exporter != nil { |
| 110 | lookupFields.AddValues(opts.Exporter.Fields()) |
| 111 | } else if opts.WebMode { |
| 112 | lookupFields.Add("url") |
| 113 | } else { |
| 114 | lookupFields.AddValues(defaultFields) |
| 115 | if opts.Comments { |
| 116 | lookupFields.Add("comments") |
| 117 | lookupFields.Remove("lastComment") |
| 118 | } |
| 119 | |
| 120 | // TODO projectsV1Deprecation |
| 121 | // Remove this section as we should no longer add projectCards |
| 122 | if opts.Detector == nil { |
| 123 | cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24) |
| 124 | opts.Detector = fd.NewDetector(cachedClient, baseRepo.RepoHost()) |
| 125 | } |
| 126 | |
| 127 | lookupFields.Add("projectItems") |
| 128 | projectsV1Support := opts.Detector.ProjectsV1() |
| 129 | if projectsV1Support == gh.ProjectsV1Supported { |
| 130 | lookupFields.Add("projectCards") |
| 131 | } |
| 132 | |
| 133 | // TODO IssueRelationshipsCleanup |
| 134 | issueFeatures, issueErr := opts.Detector.IssueFeatures() |
| 135 | if issueErr == nil && issueFeatures.IssueRelationshipsSupported { |
| 136 | lookupFields.AddValues([]string{"blockedBy", "blocking"}) |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | opts.IO.DetectTerminalTheme() |
| 141 | |
| 142 | opts.IO.StartProgressIndicator() |
| 143 | defer opts.IO.StopProgressIndicator() |
| 144 | |
| 145 | lookupFields.Add("id") |
| 146 | |
| 147 | issue, err := issueShared.FindIssueOrPR(httpClient, baseRepo, opts.IssueNumber, lookupFields.ToSlice()) |
| 148 | if err != nil { |
| 149 | return err |
| 150 | } |
| 151 | |
| 152 | if lookupFields.Contains("comments") { |
| 153 | err := preloadIssueComments(httpClient, baseRepo, issue) |
| 154 | if err != nil { |