diff --git a/pkg/cli/tabular.go b/pkg/cli/tabular.go index 48242786..16baea76 100644 --- a/pkg/cli/tabular.go +++ b/pkg/cli/tabular.go @@ -9,16 +9,18 @@ import ( ) func NewTabular(rows ...[]string) table.Model { + columnKeyProperty := "Property" + columnKeyValue := "Value" t := NewTable( - table.NewColumn("property", "Property", 15), - table.NewColumn("value", "Value", 15), + table.NewColumn(columnKeyProperty, columnKeyProperty, 37), + table.NewColumn(columnKeyValue, columnKeyValue, 37), ) tr := []table.Row{} if len(rows) == 0 { tr = append(tr, table.NewRow(table.RowData{ - "property": "No properties found", - "value": "", + columnKeyProperty: "No properties found", + columnKeyValue: "", })) } for _, r := range rows { @@ -28,11 +30,12 @@ func NewTabular(rows ...[]string) table.Model { v = r[1] } tr = append(tr, table.NewRow(table.RowData{ - "property": p, - "value": v, + columnKeyProperty: p, + columnKeyValue: v, })) } + t = t.WithRows(tr) return t } @@ -42,6 +45,7 @@ func getJsonHelper(command string) string { func PrintSuccessTable(cmd *cobra.Command, id string, t table.Model) { parent := cmd.Parent() + resourceShort := parent.Use resource := parent.Use for parent.Parent() != nil { resource = parent.Parent().Use + " " + resource @@ -54,22 +58,22 @@ func PrintSuccessTable(cmd *cobra.Command, id string, t table.Model) { } switch cmd.Use { case ActionGet: - msg.verb = fmt.Sprintf("Found %s: %s", resource, id) + msg.verb = fmt.Sprintf("Found %s: %s", resourceShort, id) msg.helper = getJsonHelper(resource + " get --id=" + id) case ActionCreate: - msg.verb = fmt.Sprintf("Created %s: %s", resource, id) + msg.verb = fmt.Sprintf("Created %s: %s", resourceShort, id) msg.helper = getJsonHelper(resource + " get --id=" + id) case ActionUpdate: - msg.verb = fmt.Sprintf("Updated %s: %s", resource, id) + msg.verb = fmt.Sprintf("Updated %s: %s", resourceShort, id) msg.helper = getJsonHelper(resource + " get --id=" + id) case ActionDelete: - msg.verb = fmt.Sprintf("Deleted %s: %s", resource, id) + msg.verb = fmt.Sprintf("Deleted %s: %s", resourceShort, id) msg.helper = getJsonHelper(resource + " list") case ActionDeactivate: - msg.verb = fmt.Sprintf("Deactivated %s: %s", resource, id) + msg.verb = fmt.Sprintf("Deactivated %s: %s", resourceShort, id) msg.helper = getJsonHelper(resource + " list") // TODO: make sure the filters are provided here to get ACTIVE/INACTIVE/ANY case ActionList: - msg.verb = fmt.Sprintf("Found %s list", resource) + msg.verb = fmt.Sprintf("Found %s list", resourceShort) msg.helper = getJsonHelper(resource + " get --id=") default: msg.verb = ""