Terminal Table is a simple ASCII table generator written in Crystal. This code was inspired by Terminal Table Ruby implementation https://github.com/tj/terminal-table
Add this to your application's shard.yml
:
dependencies:
terminal_table:
github: benoist/terminal_table.cr
require "terminal_table"
# Table with headings
table = TerminalTable.new
table.headings = ["Char", "Num"]
table << ["a", 1]
table << ["b", 2]
table << ["c", 3]
puts table.render
+------+-----+
| Char | Num |
+------+-----+
| a | 1 |
| b | 2 |
| c | 3 |
+------+-----+
# Table with a separator for each row
table = TerminalTable.new
table.headings = ["Char", "Num"]
table.separate_rows = true
table << ["a", 1]
table << ["b\nc", 2]
table << ["d", 3]
puts table.render
+------+-----+
| Char | Num |
+------+-----+
| a | 1 |
+------+-----+
| b | 2 |
| c | |
+------+-----+
| d | 3 |
+------+-----+
- [] Cell alignment
- [] Colspans
- Fork it ( https://github.com/benoist/terminal_table.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- benoist Benoist Claassen - creator, maintainer