Skip to content

Commit

Permalink
todo list: Add title to pretty output
Browse files Browse the repository at this point in the history
Add the title of the todo list item to the --pretty output, and move the
URL to a second line.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
  • Loading branch information
prarit committed May 19, 2021
1 parent 0fd6b5a commit bd03f25
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cmd/todo_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,27 @@ var todoListCmd = &cobra.Command{
log.Fatal(err)
}

var state string
var (
state string
title string
)
if todo.TargetType == "MergeRequest" {
mr, err := lab.MRGet(todo.Project.ID, id)
if err != nil {
log.Fatal(err)
}
state = mr.State
if mr.WorkInProgress {
if mr.State == "opened" && mr.WorkInProgress {
state = "draft"
}
title = mr.Title
} else {
issue, err := lab.IssueGet(todo.Project.ID, id)
if err != nil {
log.Fatal(err)
}
state = issue.State
title = issue.Title
}

switch state {
Expand All @@ -85,7 +90,7 @@ var todoListCmd = &cobra.Command{
state = red(state)
}

fmt.Printf("%s %d %s ", state, todo.ID, todo.TargetURL)
fmt.Printf("%s %d \"%s\" ", state, todo.ID, title)

name := todo.Author.Name
if lab.User() == todo.Author.Username {
Expand Down Expand Up @@ -113,6 +118,8 @@ var todoListCmd = &cobra.Command{
default:
fmt.Printf("Unknown action %s\n", todo.ActionName)
}

fmt.Printf(" %s\n", todo.TargetURL)
}
},
}
Expand Down

0 comments on commit bd03f25

Please sign in to comment.