Add --fields to notification & milestone listings #422

Merged
6543 merged 22 commits from noerw/tea:fields-flag into main 2022-09-13 19:08:19 +00:00
Showing only changes of commit c86a869e13 - Show all commits

View File

@ -42,6 +42,11 @@ var MilestoneFields = []string{
"closed items",
"open/closed issues",
6543 marked this conversation as resolved Outdated
Outdated
Review

not sure if these long and spaced column names are good, they are a not easy to apply:

tea ms -f 'open items,open/closed issues' ...

will see if I can come up with better values

not sure if these long and spaced column names are good, they are a not easy to apply: ``` tea ms -f 'open items,open/closed issues' ... ``` will see if I can come up with better values
Outdated
Review

agree 👍 - rest looks ready :)

agree :+1: - rest looks ready :)
Outdated
Review

@6543 I finally simplified the field names. I'm not exactly happy with the result, but it's good enough I guess.
This makes the PR breaking though, as we don't return the same fields anymore.

@6543 I finally simplified the field names. I'm not exactly happy with the result, but it's good enough I guess. This makes the PR breaking though, as we don't return the same fields anymore.
"due date",
"description",
"created",
"updated",
"closed",
"id",
}
type printableMilestone struct {
@ -60,10 +65,24 @@ func (m printableMilestone) FormatField(field string) string {
return fmt.Sprintf("%d", m.ClosedIssues)
case "open/closed issues": // for backwards compatibility
return fmt.Sprintf("%d/%d", m.OpenIssues, m.ClosedIssues)
case "due date":
case "deadline", "due date":
if m.Deadline != nil && !m.Deadline.IsZero() {
return FormatTime(*m.Deadline)
}
case "id":
return fmt.Sprintf("%d", m.ID)
case "description":
return m.Description
case "created":
return FormatTime(m.Created)
case "updated":
if m.Updated != nil {
return FormatTime(*m.Updated)
}
case "closed":
if m.Closed != nil {
return FormatTime(*m.Closed)
}
}
return ""
}