{"id":19267292,"url":"https://github.com/jangorman/table","last_synced_at":"2025-06-11T16:05:36.608Z","repository":{"id":63912516,"uuid":"92668799","full_name":"JanGorman/Table","owner":"JanGorman","description":"CLI tables in Swift","archived":false,"fork":false,"pushed_at":"2021-12-20T09:04:16.000Z","size":20,"stargazers_count":54,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-24T00:29:40.631Z","etag":null,"topics":["cli","spm","swift","swift-5","swift-package-manager","swift5","table"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/JanGorman.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-05-28T15:12:44.000Z","updated_at":"2025-03-09T18:36:59.000Z","dependencies_parsed_at":"2023-01-14T13:15:55.970Z","dependency_job_id":null,"html_url":"https://github.com/JanGorman/Table","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/JanGorman/Table","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanGorman%2FTable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanGorman%2FTable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanGorman%2FTable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanGorman%2FTable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JanGorman","download_url":"https://codeload.github.com/JanGorman/Table/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JanGorman%2FTable/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259292932,"owners_count":22835505,"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":["cli","spm","swift","swift-5","swift-package-manager","swift5","table"],"created_at":"2024-11-09T20:11:26.328Z","updated_at":"2025-06-11T16:05:36.557Z","avatar_url":"https://github.com/JanGorman.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swift Tables\n\n[![CI](https://github.com/JanGorman/Table/workflows/CI/badge.svg)](https://github.com/JanGorman/Table/actions?query=workflow%3ACI)\n[![SPM](https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat)](https://swift.org/package-manager)\n[![codecov](https://codecov.io/gh/JanGorman/Table/branch/master/graph/badge.svg)](https://codecov.io/gh/JanGorman/Table)\n\nWorking on CLI tools in Swift? Need to display tables? Continue reading.\n\nAdd the dependency to your `Package.swift` file:\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n    name: \"My awesome CLI tool\"\n    dependencies: [\n        .package(\n            url: \"https://github.com/JanGorman/Table\",\n            from: \"1.0.0\"\n        )\n    ]\n)\n```\n\n### Basic Usage\n\n```swift\nimport Table\n\nfunc doSomething() throws {\n    let data = [\n      [\"0A\", \"0B\", \"0C\"],\n      [\"1A\", \"1B\", \"1C\"],\n      [\"2A\", \"2B\", \"2C\"],\n    ]\n\n    let table = try Table(data: data).table()\n\n    print(table)\n}\n\n```\n\nResults in a pretty table:\n\n```\n╔════╤════╤════╗\n║ 0A │ 0B │ 0C ║\n╟────┼────┼────╢\n║ 1A │ 1B │ 1C ║\n╟────┼────┼────╢\n║ 2A │ 2B │ 2C ║\n╚════╧════╧════╝\n```\n\n### Alignment\n\nYou can align your table rows by passing in a `Configuration`:\n\n```swift\nimport Table\n\nfunc doSomething() throws {\n    let data = [\n      [\"0A\", \"0B\", \"0C\"],\n    ]\n    // Give alignment and a minimum width\n    let columns = [\n      Column(alignment: .left, width: 10),\n      Column(alignment: .center, width: 10),\n      Column(alignment: .right, width: 10)\n    ]\n    let configuration = Configuration(columns: columns)\n    let table = try Table(data: data).table()\n\n    print(table)\n}\n```\n\nResults in:\n\n```\n╔══════════╤══════════╤══════════╗\n║0A        │    0B    │        0C║\n╚══════════╧══════════╧══════════╝\n```\n\n### Padding\n\nThe `Configuration` also allows for padding:\n\n```swift\nimport Table\n\nfunc doSomething() throws {\n    let data = [\n      [\"0A\", \"0B\", \"0C\"],\n    ]\n    let columns = [\n      Column(paddingLeft: 3, paddingRight: 4),\n      Column(paddingLeft: 8, paddingRight: 8),\n      Column(paddingLeft: 3, paddingRight: 4)\n    ]\n    let configuration = Configuration(columns: columns)\n    let table = try Table(data: data).table()\n\n    print(table)\n}\n```\n\nWould give you:\n\n```\n╔═════════╤══════════════════╤═════════╗\n║   0A    │        0B        │   0C    ║\n╚═════════╧══════════════════╧═════════╝\n```\n\n### Custom Border Style\n\nTo use a custom border for your tables simply create a `struct` conforming to the `Border` protocol and pass it as part of a custom `Configuration`. For example:\n\n```swift\nimport Table\n\nstruct CustomBorder: Border {\n  public let topBody = \"─\"\n  public let topJoin = \"┬\"\n  public let topLeft = \"┌\"\n  public let topRight = \"┐\"\n\n  public let bottomBody = \"─\"\n  public let bottomJoin = \"┴\"\n  public let bottomLeft = \"└\"\n  public let bottomRight = \"┘\"\n\n  public let bodyLeft = \"│\"\n  public let bodyRight = \"│\"\n  public let bodyJoin = \"│\"\n\n  public let joinBody = \"─\"\n  public let joinLeft = \"├\"\n  public let joinRight = \"┤\"\n  public let joinJoin = \"┼\"\n}\n\nfunc doSomething() throws -\u003e String {\n  …\n  let configuration = Configuration(border: CustomBorder(), columns: columns)\n  return try Table(data: data).table()\n}\n```\n\n## Licence\n\nTable is released under the MIT license. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjangorman%2Ftable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjangorman%2Ftable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjangorman%2Ftable/lists"}