Skip to content

Commit

Permalink
fix: get json format output working
Browse files Browse the repository at this point in the history
  • Loading branch information
vprasanth committed Jan 25, 2021
1 parent 56db5ed commit 30944b7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions internal/display/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ import (
)

type ruleView struct {
rule management.Rule
Name string
Enabled bool
Id string
Order int
}

func (v *ruleView) AsTableHeader() []string {
return []string{"Id", "Name", "Status", "Order"}
return []string{"Id", "Name", "Enabled", "Order"}
}

func (v *ruleView) AsTableRow() []string {
return []string{*v.rule.ID, *v.rule.Name, isEnabled(*v.rule.Enabled), fmt.Sprintf("%d", *v.rule.Order)}
return []string{v.Id, v.Name, isEnabled(v.Enabled), fmt.Sprintf("%d", v.Order)}
}

func isEnabled(value bool) string {
Expand All @@ -38,7 +41,10 @@ func (r *Renderer) RulesList(ruleList *management.RuleList) {

for _, rule := range ruleList.Rules {
res = append(res, &ruleView{
rule: *rule,
Name: *rule.Name,
Id: *rule.ID,
Enabled: *rule.Enabled,
Order: *rule.Order,
})
}

Expand Down

0 comments on commit 30944b7

Please sign in to comment.