Skip to content

Commit

Permalink
printer: make printer display []string
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelL committed Oct 5, 2020
1 parent 30fccf0 commit b324f8a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions printer/table/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"reflect"
"strconv"
"strings"
"time"

"github.com/cycloidio/cycloid-cli/printer"
Expand Down Expand Up @@ -33,6 +34,20 @@ func entryFromStruct(obj reflect.Value, h []string) []string {
values = append(values, value.String())
case reflect.Uint32:
values = append(values, strconv.FormatInt(int64(value.Uint()), 10))
case reflect.Slice:
// Render Slice of strings
typ := value.Type().Elem()
if typ == reflect.TypeOf(string("")) {
stringSlice := make([]string, value.Len())
for i := 0; i < value.Len(); i++ {
if value.Index(i).Kind() == reflect.String {
stringSlice[i] = value.Index(i).String()
}
}
values = append(values, strings.Join(stringSlice[:], "\n"))
} else {
values = append(values, value.Kind().String())
}
case reflect.Ptr:
elt := value.Elem()
switch elt.Kind() {
Expand Down

0 comments on commit b324f8a

Please sign in to comment.