MCPcopy Create free account
hub / github.com/cloudwan/gohan / formatOutputTable

Method formatOutputTable

cli/client/output.go:43–59  ·  view source on GitHub ↗
(s *schema.Schema, rawResult interface{})

Source from the content-addressed store, hash-verified

41}
42
43func (gohanClientCLI *GohanClientCLI) formatOutputTable(s *schema.Schema, rawResult interface{}) string {
44 buffer := bytes.NewBufferString("")
45 for k, v := range rawResult.(map[string]interface{}) {
46 if k == errorKey {
47 return fmt.Sprintf("%v", v)
48 }
49 switch v.(type) {
50 case []interface{}:
51 gohanClientCLI.createResourcesTable(s, buffer, v.([]interface{}))
52 case map[string]interface{}:
53 gohanClientCLI.createSingleResourceTable(s, buffer, v.(map[string]interface{}))
54 default:
55 return fmt.Sprintf("%v", v)
56 }
57 }
58 return buffer.String()
59}
60
61func (gohanClientCLI *GohanClientCLI) createResourcesTable(s *schema.Schema, buffer *bytes.Buffer, resources []interface{}) {
62 table := tablewriter.NewWriter(buffer)

Callers 1

formatOutputMethod · 0.95

Calls 3

createResourcesTableMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected