chore: implement cli list organization members (#13555)

example cli command: 
`coder organization members`
This commit is contained in:
Steven Masley
2024-06-12 10:07:12 -10:00
committed by GitHub
parent bbe23edc7d
commit d0fc81a51c
10 changed files with 317 additions and 45 deletions
+18
View File
@@ -205,6 +205,24 @@ func renderTable(out any, sort string, headers table.Row, filterColumns []string
}
}
// Guard against nil dereferences
if v != nil {
rt := reflect.TypeOf(v)
switch rt.Kind() {
case reflect.Slice:
// By default, the behavior is '%v', which just returns a string like
// '[a b c]'. This will add commas in between each value.
strs := make([]string, 0)
vt := reflect.ValueOf(v)
for i := 0; i < vt.Len(); i++ {
strs = append(strs, fmt.Sprintf("%v", vt.Index(i).Interface()))
}
v = "[" + strings.Join(strs, ", ") + "]"
default:
// Leave it as it is
}
}
rowSlice[i] = v
}