X Tutup
Skip to content

Commit caf26e4

Browse files
committed
Show the issue state for viewing issues in CLI
1 parent faa4bed commit caf26e4

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

command/issue.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,25 @@ func issueView(cmd *cobra.Command, args []string) error {
251251
func printIssuePreview(out io.Writer, issue *api.Issue) error {
252252
coloredLabels := labelList(*issue)
253253
if coloredLabels != "" {
254-
coloredLabels = utils.Gray(fmt.Sprintf("(%s)", coloredLabels))
254+
coloredLabels = fmt.Sprintf("%s", coloredLabels)
255255
}
256256

257+
now := time.Now()
258+
ago := now.Sub(issue.CreatedAt)
259+
issueStateColorFunc := utils.ColorFuncForState(issue.State)
260+
257261
fmt.Fprintln(out, utils.Bold(issue.Title))
258-
fmt.Fprintln(out, utils.Gray(fmt.Sprintf(
259-
"opened by %s. %s. %s",
262+
fmt.Fprintf(out, "%s", issueStateColorFunc(issue.State))
263+
fmt.Fprint(out, utils.Gray(fmt.Sprintf(
264+
" • %s opened %s • %s • ",
260265
issue.Author.Login,
266+
utils.FuzzyAgo(ago),
261267
utils.Pluralize(issue.Comments.TotalCount, "comment"),
262-
coloredLabels,
263268
)))
269+
if coloredLabels != "" {
270+
fmt.Fprintf(out, "%s", utils.Gray(coloredLabels))
271+
}
272+
fmt.Fprintf(out, "\n")
264273

265274
if issue.Body != "" {
266275
fmt.Fprintln(out)

0 commit comments

Comments
 (0)
X Tutup