Skip to content

Commit

Permalink
Merge pull request #116 from debeando/refact-table
Browse files Browse the repository at this point in the history
refact - terminal table implementation
  • Loading branch information
nstrappazzonc committed Nov 17, 2023
2 parents 82ac1d4 + a8e2d82 commit 58ed637
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 13 deletions.
4 changes: 2 additions & 2 deletions aws/database/describe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ func NewCommand() *cobra.Command {
}

tbl := table.New("ATTRIBUTE", "VALUE")
tbl.SetFirstColumnAlignment(table.Right)
tbl.Column(0, table.Column{Alignment: table.Right})
for k, v := range instance.JSON() {
tbl.AddRow(k, v)
tbl.Add(k, v)
}
tbl.Print()
},
Expand Down
2 changes: 1 addition & 1 deletion aws/database/logs/list/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewCommand() *cobra.Command {

tbl := table.New("FILE", "SIZE")
for _, log := range logs {
tbl.AddRow(log.FileName, log.Size)
tbl.Add(log.FileName, log.Size)
}
tbl.Print()
},
Expand Down
2 changes: 1 addition & 1 deletion aws/database/parameters/describe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewCommand() *cobra.Command {

tbl := table.New("NAME", "VALUES", "APPLY METHOD", "APPLY TYPE", "MODIFIABLE")
for _, parameter := range parameters {
tbl.AddRow(parameter.Name, parameter.Value, parameter.ApplyMethod, parameter.ApplyType, parameter.IsModifiable)
tbl.Add(parameter.Name, parameter.Value, parameter.ApplyMethod, parameter.ApplyType, parameter.IsModifiable)
}
tbl.Print()
},
Expand Down
2 changes: 1 addition & 1 deletion aws/database/parameters/list/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewCommand() *cobra.Command {

tbl := table.New("NAME", "DESCRIPTION", "FAMILY")
for _, parameter := range parameters {
tbl.AddRow(parameter.Name, parameter.Description, parameter.Family)
tbl.Add(parameter.Name, parameter.Description, parameter.Family)
}
tbl.Print()

Expand Down
2 changes: 1 addition & 1 deletion aws/databases/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewCommand() *cobra.Command {

tbl := table.New("ENGINE", "VERSION", "IDENTIFIER", "CLASS", "STATUS")
for _, instance := range instances {
tbl.AddRow(instance.Engine, instance.Version, instance.Identifier, instance.Class, instance.Status)
tbl.Add(instance.Engine, instance.Version, instance.Identifier, instance.Class, instance.Status)
}
tbl.Print()
},
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module zenit
go 1.21

require (
github.com/aws/aws-sdk-go v1.47.3
github.com/debeando/go-common v0.4.5
github.com/aws/aws-sdk-go v1.48.0
github.com/debeando/go-common v0.4.7
github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c
github.com/kardianos/service v1.2.2
github.com/shirou/gopsutil v3.21.11+incompatible
Expand All @@ -13,14 +13,14 @@ require (
)

require (
github.com/fatih/color v1.15.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/klauspost/compress v1.17.3 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
Expand All @@ -33,8 +33,8 @@ require (
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.mongodb.org/mongo-driver v1.12.1 // indirect
golang.org/x/crypto v0.14.0 // indirect
go.mongodb.org/mongo-driver v1.13.0 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
Expand Down
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ github.com/aws/aws-sdk-go v1.46.6 h1:6wFnNC9hETIZLMf6SOTN7IcclrOGwp/n9SLp8Pjt6E8
github.com/aws/aws-sdk-go v1.46.6/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go v1.47.3 h1:e0H6NFXiniCpR8Lu3lTphVdRaeRCDLAeRyTHd1tJSd8=
github.com/aws/aws-sdk-go v1.47.3/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go v1.48.0 h1:1SeJ8agckRDQvnSCt1dGZYAwUaoD2Ixj6IaXB4LCv8Q=
github.com/aws/aws-sdk-go v1.48.0/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -19,8 +21,12 @@ github.com/debeando/go-common v0.4.4 h1:uDYGYC+I+/ZlOZ27w8FHUKiaGzfsMaxzASJnPGai
github.com/debeando/go-common v0.4.4/go.mod h1:0u1RTk8umumGN+i+2V07g0itNWfDIUU19bsxEeFLMG4=
github.com/debeando/go-common v0.4.5 h1:XVE8thhXVdNoLuCOQokq3TZePxbPKv2vRqwBeKeK8Ds=
github.com/debeando/go-common v0.4.5/go.mod h1:0u1RTk8umumGN+i+2V07g0itNWfDIUU19bsxEeFLMG4=
github.com/debeando/go-common v0.4.7 h1:TDWg1estW1Bah7TQvJ3qZvhP0RI3eG/2QbinuXdEGbw=
github.com/debeando/go-common v0.4.7/go.mod h1:h1hsqdnmtWyINN59EWVD58WmHEDg0gzMz8OdJs4mUH0=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
Expand Down Expand Up @@ -49,6 +55,8 @@ github.com/klauspost/compress v1.17.1 h1:NE3C767s2ak2bweCZo3+rdP4U/HoyVXLv/X9f2g
github.com/klauspost/compress v1.17.1/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4=
github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/compress v1.17.3 h1:qkRjuerhUU1EmXLYGkSH6EZL+vPSxIrYjLNAK4slzwA=
github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
Expand Down Expand Up @@ -93,12 +101,16 @@ github.com/yusufpapurcu/wmi v1.2.3 h1:E1ctvB7uKFMOJw3fdOW32DwGE9I7t++CRUEMKvFoFi
github.com/yusufpapurcu/wmi v1.2.3/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecqgE=
go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ=
go.mongodb.org/mongo-driver v1.13.0 h1:67DgFFjYOCMWdtTEmKFpV3ffWlFnh+CYZ8ZS/tXWUfY=
go.mongodb.org/mongo-driver v1.13.0/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
Expand Down
2 changes: 1 addition & 1 deletion mysql/digest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewCommand() *cobra.Command {
max := queries.ScoreMax()

for index := range *queries {
tbl.AddRow(
tbl.Add(
(*queries)[index].ID,
formatScore(min, max, (*queries)[index].Score),
(*queries)[index].Count,
Expand Down

0 comments on commit 58ed637

Please sign in to comment.