@@ -9,16 +9,18 @@ import (
99)
1010
1111func NewTabular (rows ... []string ) table.Model {
12+ columnKeyProperty := "Property"
13+ columnKeyValue := "Value"
1214 t := NewTable (
13- table .NewColumn ("property" , "Property" , 15 ),
14- table .NewColumn ("value" , "Value" , 15 ),
15+ table .NewColumn (columnKeyProperty , columnKeyProperty , 37 ),
16+ table .NewColumn (columnKeyValue , columnKeyValue , 37 ),
1517 )
1618
1719 tr := []table.Row {}
1820 if len (rows ) == 0 {
1921 tr = append (tr , table .NewRow (table.RowData {
20- "property" : "No properties found" ,
21- "value" : "" ,
22+ columnKeyProperty : "No properties found" ,
23+ columnKeyValue : "" ,
2224 }))
2325 }
2426 for _ , r := range rows {
@@ -28,11 +30,12 @@ func NewTabular(rows ...[]string) table.Model {
2830 v = r [1 ]
2931 }
3032 tr = append (tr , table .NewRow (table.RowData {
31- "property" : p ,
32- "value" : v ,
33+ columnKeyProperty : p ,
34+ columnKeyValue : v ,
3335 }))
3436 }
3537
38+ t = t .WithRows (tr )
3639 return t
3740}
3841
@@ -42,6 +45,7 @@ func getJsonHelper(command string) string {
4245
4346func PrintSuccessTable (cmd * cobra.Command , id string , t table.Model ) {
4447 parent := cmd .Parent ()
48+ resourceShort := parent .Use
4549 resource := parent .Use
4650 for parent .Parent () != nil {
4751 resource = parent .Parent ().Use + " " + resource
@@ -54,22 +58,22 @@ func PrintSuccessTable(cmd *cobra.Command, id string, t table.Model) {
5458 }
5559 switch cmd .Use {
5660 case ActionGet :
57- msg .verb = fmt .Sprintf ("Found %s: %s" , resource , id )
61+ msg .verb = fmt .Sprintf ("Found %s: %s" , resourceShort , id )
5862 msg .helper = getJsonHelper (resource + " get --id=" + id )
5963 case ActionCreate :
60- msg .verb = fmt .Sprintf ("Created %s: %s" , resource , id )
64+ msg .verb = fmt .Sprintf ("Created %s: %s" , resourceShort , id )
6165 msg .helper = getJsonHelper (resource + " get --id=" + id )
6266 case ActionUpdate :
63- msg .verb = fmt .Sprintf ("Updated %s: %s" , resource , id )
67+ msg .verb = fmt .Sprintf ("Updated %s: %s" , resourceShort , id )
6468 msg .helper = getJsonHelper (resource + " get --id=" + id )
6569 case ActionDelete :
66- msg .verb = fmt .Sprintf ("Deleted %s: %s" , resource , id )
70+ msg .verb = fmt .Sprintf ("Deleted %s: %s" , resourceShort , id )
6771 msg .helper = getJsonHelper (resource + " list" )
6872 case ActionDeactivate :
69- msg .verb = fmt .Sprintf ("Deactivated %s: %s" , resource , id )
73+ msg .verb = fmt .Sprintf ("Deactivated %s: %s" , resourceShort , id )
7074 msg .helper = getJsonHelper (resource + " list" ) // TODO: make sure the filters are provided here to get ACTIVE/INACTIVE/ANY
7175 case ActionList :
72- msg .verb = fmt .Sprintf ("Found %s list" , resource )
76+ msg .verb = fmt .Sprintf ("Found %s list" , resourceShort )
7377 msg .helper = getJsonHelper (resource + " get --id=<id>" )
7478 default :
7579 msg .verb = ""
0 commit comments