(opts *StatusOptions)
| 61 | } |
| 62 | |
| 63 | func statusRun(opts *StatusOptions) error { |
| 64 | httpClient, err := opts.HttpClient() |
| 65 | if err != nil { |
| 66 | return err |
| 67 | } |
| 68 | apiClient := api.NewClientFromHTTP(httpClient) |
| 69 | |
| 70 | baseRepo, err := opts.BaseRepo() |
| 71 | if err != nil { |
| 72 | return err |
| 73 | } |
| 74 | |
| 75 | currentUser, err := api.CurrentLoginName(apiClient, baseRepo.RepoHost()) |
| 76 | if err != nil { |
| 77 | return err |
| 78 | } |
| 79 | |
| 80 | options := api.IssueStatusOptions{ |
| 81 | Username: currentUser, |
| 82 | Fields: defaultFields, |
| 83 | } |
| 84 | if opts.Exporter != nil { |
| 85 | options.Fields = opts.Exporter.Fields() |
| 86 | } |
| 87 | issuePayload, err := api.IssueStatus(apiClient, baseRepo, options) |
| 88 | if err != nil { |
| 89 | return err |
| 90 | } |
| 91 | |
| 92 | err = opts.IO.StartPager() |
| 93 | if err != nil { |
| 94 | fmt.Fprintf(opts.IO.ErrOut, "error starting pager: %v\n", err) |
| 95 | } |
| 96 | defer opts.IO.StopPager() |
| 97 | |
| 98 | if opts.Exporter != nil { |
| 99 | data := map[string]interface{}{ |
| 100 | "createdBy": issuePayload.Authored.Issues, |
| 101 | "assigned": issuePayload.Assigned.Issues, |
| 102 | "mentioned": issuePayload.Mentioned.Issues, |
| 103 | } |
| 104 | return opts.Exporter.Write(opts.IO, data) |
| 105 | } |
| 106 | |
| 107 | out := opts.IO.Out |
| 108 | |
| 109 | fmt.Fprintln(out, "") |
| 110 | fmt.Fprintf(out, "Relevant issues in %s\n", ghrepo.FullName(baseRepo)) |
| 111 | fmt.Fprintln(out, "") |
| 112 | |
| 113 | prShared.PrintHeader(opts.IO, "Issues assigned to you") |
| 114 | if issuePayload.Assigned.TotalCount > 0 { |
| 115 | issueShared.PrintIssues(opts.IO, time.Now(), " ", issuePayload.Assigned.TotalCount, issuePayload.Assigned.Issues) |
| 116 | } else { |
| 117 | message := " There are no issues assigned to you" |
| 118 | prShared.PrintMessage(opts.IO, message) |
| 119 | } |
| 120 | fmt.Fprintln(out) |
no test coverage detected