tableOutput prints the list of items as columns, where the first row is the list of headers.
(list []string, c *columnize.Config)
| 102 | // tableOutput prints the list of items as columns, where the first row is |
| 103 | // the list of headers. |
| 104 | func tableOutput(list []string, c *columnize.Config) string { |
| 105 | if len(list) == 0 { |
| 106 | return "" |
| 107 | } |
| 108 | |
| 109 | delim := "|" |
| 110 | if c != nil && c.Delim != "" { |
| 111 | delim = c.Delim |
| 112 | } |
| 113 | |
| 114 | underline := "" |
| 115 | headers := strings.Split(list[0], delim) |
| 116 | for i, h := range headers { |
| 117 | h = strings.TrimSpace(h) |
| 118 | u := strings.Repeat("-", len(h)) |
| 119 | |
| 120 | underline = underline + u |
| 121 | if i != len(headers)-1 { |
| 122 | underline = underline + delim |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | list = append(list, "") |
| 127 | copy(list[2:], list[1:]) |
| 128 | list[1] = underline |
| 129 | |
| 130 | return columnOutput(list, c) |
| 131 | } |
| 132 | |
| 133 | // parseArgsData parses the given args in the format key=value into a map of |
| 134 | // the provided arguments. The given reader can also supply key=value pairs. |
no test coverage detected
searching dependent graphs…