diff --git a/actions.go b/actions.go index a70279d..231c180 100644 --- a/actions.go +++ b/actions.go @@ -294,6 +294,7 @@ func ActionViewCard(_ []string) { } else { fmt.Printf("Assignee: Unassigned\n") } + fmt.Printf("Number of comments: %d\n", len(issue.Fields.Comments.Comments)) } func ActionViewDescription(_ []string) { @@ -309,6 +310,25 @@ func ActionViewDescription(_ []string) { println(issue.Fields.Description) } +func ActionViewComments(_ []string) { + if !HasIssue() { + printError("No issue selected", nil) + return + } + issue, err := GetIssue(GetIssueKey()) + if err != nil { + printError("Failed to get issue", err) + return + } + for i, comment := range issue.Fields.Comments.Comments { + if i != 0 { + println() + } + fmt.Printf("%s at %s:\n", red(comment.Author.DisplayName), blue(comment.Created)) + fmt.Printf(" %s\n", comment.Body) + } +} + func ActionSetStatus(_ []string) { if !HasIssue() { printError("No issue selected", nil) diff --git a/commands.go b/commands.go index 8361a05..2d9bf87 100644 --- a/commands.go +++ b/commands.go @@ -51,8 +51,9 @@ var CommandTree = []CommandArg{ option("my", command("issue", ActionUseMyIssue).WithHelp("Use an issue assigned to me")), ).WithHelp("Select something for further commands"), option("view", - command("card", ActionViewCard).WithHelp("View general information about the ticket"), - command("description", ActionViewDescription).WithHelp("View description of a ticket"), + command("card", ActionViewCard).WithHelp("View general information about the issue"), + command("description", ActionViewDescription).WithHelp("View description of a issue"), + command("comments", ActionViewComments).WithHelp("View comments of an issue"), ).WithHelp("View data about something"), option("set", command("status", ActionSetStatus).WithHelp("Set status of a ticket"),