{"id":13482655,"url":"https://github.com/epoch/tallboy","last_synced_at":"2025-10-17T11:39:27.536Z","repository":{"id":52503623,"uuid":"174291872","full_name":"epoch/tallboy","owner":"epoch","description":"Declarative API for drawing unicode/ascii character tables in crystal lang","archived":false,"fork":false,"pushed_at":"2021-04-27T11:29:38.000Z","size":86,"stargazers_count":58,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-07T02:02:21.830Z","etag":null,"topics":["ascii-art","cli","colspan","crystal-lang","table","terminal","tty"],"latest_commit_sha":null,"homepage":"","language":"Crystal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/epoch.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-07T07:15:34.000Z","updated_at":"2025-01-13T13:59:46.000Z","dependencies_parsed_at":"2022-09-06T14:24:14.837Z","dependency_job_id":null,"html_url":"https://github.com/epoch/tallboy","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epoch%2Ftallboy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epoch%2Ftallboy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epoch%2Ftallboy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/epoch%2Ftallboy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/epoch","download_url":"https://codeload.github.com/epoch/tallboy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252798838,"owners_count":21805884,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ascii-art","cli","colspan","crystal-lang","table","terminal","tty"],"created_at":"2024-07-31T17:01:04.147Z","updated_at":"2025-10-17T11:39:22.513Z","avatar_url":"https://github.com/epoch.png","language":"Crystal","funding_links":[],"categories":["CLI Utils"],"sub_categories":[],"readme":"# tallboy\n\nGenerate pretty **Unicode**, **ASCII** or **Markdown** tables on the terminal for your command line programs. \n\n[tallboy](https://github.com/epoch/tallboy) is a DSL for quickly creating text based tables in [Crystal](https://crystal-lang.org/).\n\n## Quick start\n```crystal\ntable = Tallboy.table do\n  header [\"name\", \"hex\"]\n  row [\"mistyrose\",       \"#ffe4e1\"]\n  row [\"darkolivegreen\",  \"#556b2f\"]\n  row [\"papayawhip\",      \"#ffefd5\"]\nend\n\nputs table\n```\n```\n┌────────────────┬─────────┐\n│ name           │ hex     │\n├────────────────┼─────────┤\n│ mistyrose      │ #ffe4e1 │\n│ darkolivegreen │ #556b2f │\n│ papayawhip     │ #ffefd5 │\n└────────────────┴─────────┘\n```\n```crystal\n# full API\n\ntable = Tallboy.table do\n  # define 3 columns. set first column width to 12 \u0026 align right \n  columns do \n    add \"size\", width: 12, align: :right\n    add \"http method\"\n    add \"path\"\n  end\n\n  # add header with multiple lines\n  header \"good\\nfood\\nhunting\", align: :right\n\n  # add header with column span on one cell\n  header do\n    cell \"\"\n    cell \"routes\", span: 2\n  end\n  \n  # add header inferred from column definitions\n  # [size, http method, path]\n  header\n\n  rows [\n    [\"207 B\", \"post\", \"/dishes\"],\n    [\"1.3 kB\", \"get\", \"/dishes\"],\n    [\"910 B\", \"patch\", \"/dishes/:id\"],\n    [\"10.2 kB\", \"delete\", \"/dishes/:id\"],\n  ]\nend\n\nputs table\n```\n```\n┌────────────────────────────────────────┐\n│                                   good │\n│                                   food │\n│                                hunting │\n├────────────┬───────────────────────────┤\n│            │ routes                    │\n├────────────┼─────────────┬─────────────┤\n│       size │ http method │ path        │\n├────────────┼─────────────┼─────────────┤\n│      207 B │ post        │ /dishes     │\n│     1.3 kB │ get         │ /dishes     │\n│      910 B │ patch       │ /dishes/:id │\n│    10.2 kB │ delete      │ /dishes/:id │\n└────────────┴─────────────┴─────────────┘\n\n# draw border joints correctly even with different span sizes :)\n```\n\n## Top Features\n\n- spanning cells across muliple columns and entire rows\n- simple, readable and flexible API\n- text alignment (left, right, center)\n- set width and alignment for entire columns with column definitions\n- static type checking for almost all DSL options\n- support multi-line cells with the newline character\n- full custom styling or choose from multiple border styles including ascii, unicode and markdown\n- render directly into IO for better performance\n\n## Install it as a shard\n\n1. Add the dependency to your `shard.yml`:\n\n```yaml\ndependencies:\n  tallboy:\n    github: epoch/tallboy\n```\n\n2. Run `shards install`\n\n## Simple tutorial\n\n1. create a table with `Tallboy.table`\n\n```crystal\ntable = Tallboy.table do\nend\n```\n\n2. define columns. here we will define a 4 column table with `columns`.\n\n```crystal\ntable = Tallboy.table do\n  columns do\n    add \"id\"\n    add \"name\"\n    add \"description\"\n    add \"price\n  end\nend\n```\n\n3. add rows. you can add single row with `row` or nested arrays with `rows`. values can be **any object that has a `to_s` method**.\n\n```crystal\ntable = Tallboy.table do\n  columns do\n    add \"id\"\n    add \"name\"\n    add \"description\"\n    add \"price\"\n  end\n\n  rows [\n    [1, \"cake\", \"goes well with pudding\", 3.4],\n    [2, \"pudding\", \"so good with cake!\", 12.5],\n    [3, \"burger\", \"from the reburgulator\", 22.9],\n    [4, \"chips\", \"wait you mean fries?\", 5],\n  ]\nend\n```\n\n4. add header. we can manually add header with `header` with arguments or pass no arguments to inferred from column definitions. header is just a row with a border below.\n\n```crystal\ntable = Tallboy.table do\n  columns do\n    add \"id\"\n    add \"name\"\n    add \"description\"\n    add \"price\"\n  end\n\n  header\n  rows [\n    [1, \"cake\", \"goes well with pudding\", 3.4],\n    [2, \"pudding\", \"so good with cake!\", 12.5],\n    [3, \"burger\", \"from the reburgulator\", 22.9],\n    [4, \"chips\", \"wait you mean fries?\", 5],\n  ]\nend\n```\n\n5. add footer. we can add footer with `footer`. footer is a row with border on top. If we pass a string instead of an array it will auto span all 4 columns based on the other rows defined in this table. nice! :)\n\n```crystal\ntable = Tallboy.table do\n  columns do\n    add \"id\"\n    add \"name\"\n    add \"description\"\n    add \"price\"\n  end\n  header\n  rows [\n    [1, \"cake\", \"goes well with pudding\", 3.4],\n    [2, \"pudding\", \"so good with cake!\", 12.5],\n    [3, \"burger\", \"from the reburgulator\", 22.9],\n    [4, \"chips\", \"wait you mean fries?\", 5],\n  ]\n  footer \"43.8\"\nend\n```\n\n6. set column span, widths and aligments. `header`, `row` and `footer` also take blocks. here we can set column span on a cell within the footer.\n\n```crystal\ntable = Tallboy.table do\n  columns do\n    add \"id\"\n    add \"name\"\n    add \"description\"\n    add \"price\"\n  end\n  header\n  rows [\n    [1, \"cake\", \"goes well with pudding\", 3.4],\n    [2, \"pudding\", \"so good with cake!\", 12.5],\n    [3, \"burger\", \"from the reburgulator\", 22.9],\n    [4, \"chips\", \"wait you mean fries?\", 5],\n  ]\n  footer do\n    cell \"total\", span: 3\n    cell \"43.8\"\n  end\nend\n```\n\n7. render with different border styles.\n\n```crystal\nputs table.render # defaults to unicode\nputs table.render(:ascii) # classic look\n\n# markdown does not support column spans and outer edge borders\n# turning off top and bottom border with border set to `:none`\n\ntable = Tallboy.table(border: :none) do\n  header [\"name\", \"hex\"]\n  row [\"mistyrose\",       \"#ffe4e1\"]\n  row [\"darkolivegreen\",  \"#556b2f\"]\n  row [\"papayawhip\",      \"#ffefd5\"]\nend\n\nputs table.render(:markdown) \n```\n\n```\n| name           | hex     |\n|----------------|---------|\n| mistyrose      | #ffe4e1 |\n| darkolivegreen | #556b2f |\n| papayawhip     | #ffefd5 |\n```\n\n8. tallboy supports rendering into custom IO\n\n```crystal\ntable.render(IO::Memory.new)\n\nputs(\n  Tallboy.table do\n    row [1,2,3]\n  end\n)\n```\n\n## How it works\n\nMost components in tallboy can be invoked separately. The design philosophy is inspired by how web browsers renders HTML.\n\n```\n┌───────────────────────────────────────────────────────────┐\n│                  web browser vs tallboy                   │\n├───────────────────────────────────────────────────────────┤\n│ HTML ──\u003e Document Object Model ──\u003e render tree ──\u003e pixels │\n│ DSL  ──\u003e Table Object Model    ──\u003e render tree ──\u003e text   │\n└───────────────────────────────────────────────────────────┘\n```\n\n```crystal\ndata = [\n  [1,2,3],\n  [4,5,6]\n]\n\n# TableBuilder is the DSL that returns an object model\ntable_object_model = Tallboy::TableBuilder.new do \n  rows(data)\nend\n\n# ComputedTableBuilder takes the object model and calculate widths for each cell \ncomputed_table = Tallboy::ComputedTableBuilder.new(table_object_model).build\n\n# RenderTreeBuilder work out borders, spans and organize into nodes to rendering\nrender_tree = Tallboy::RenderTreeBuilder.new(computed_table).build\n\n# render into output with unicode border style\nio = Tallboy::Renderer.new(render_tree).render\n\n```\n\n## API\n\nfor more examples checkout `tallboy_spec.cr`\n\n## Contributing\n\nIssues and pull requests are welcome on GitHub at (https://github.com/epoch/tallboy)\n\n- [Daniel Tsui](https://github.com/epoch) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepoch%2Ftallboy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fepoch%2Ftallboy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fepoch%2Ftallboy/lists"}