rocdev-foundation / medera

Is a chat bot the new "Hello, World"?
GNU General Public License v3.0
1 stars 2 forks source link

Format-Table #25

Closed geowa4 closed 7 years ago

geowa4 commented 7 years ago

As mentioned in #24, we need to format output to be more readable. Formatting as JSON is often sufficient, especially for a bot like this, but tables are nice too. Since we're working with a text interface, an ASCII table is sufficient. The first row must display the names of each property in all of the objects. The table shall be bordered using +, =, -, and | characters. The corners of each cell shall be rendered with a +. All vertical lines shall be rendered with a |. The horizontal lines above and below the header row shall be rendered with =. All other horizontal lines will be rendered with a -. Place a single space on each side of the value in the cell. The width of each column is therefore two spaces wider than the widest element.

Assuming a skill's JSON output as [{"name":"asdf","foo":111,"bar":"one"},{"name":"asdf","foo":222,"bar":"two"}], the following must be the output of Format-Table.

+======+=====+=====+
| name | foo | bar |
+======+=====+=====+
| asdf | 111 | one |
+------+-----+-----+
| fasd | 222 | two |
+------+-----+-----+

Invoking this formatter is done via piping: Get-Data | Format-Table.

geowa4 commented 7 years ago

Superseded by #28 and #29.