Build Table for command line tools for macOS written in Swift
┌─────────┬─────┬────────────────┐
│ Name │ Age │ City │
├─────────┼─────┼────────────────┤
│ Matheus │ 23 │ São Paulo │
├─────────┼─────┼────────────────┤
│ Alice │ 30 │ Rio de Janeiro │
└─────────┴─────┴────────────────┘
Default with terminal color
import CLITable
let headers = ["Name", "Age", "City"]
var table = CLITable(headers: headers)
let rows = [
["Matheus", "23", "São Paulo"],
["Alice", "30", "Rio de Janeiro"]
]
table.addRows(rows)
table.showTable()
If you prefer, you can add the row like this
let headers = ["Name", "Age", "City"]
var table = CLITable(headers: headers)
table.addRow(["Matheus", "23", "São Paulo"])
table.addRow(["Matheus", "23", "São Paulo"])
table.showTable()
To customize the table you can add color to the line and text or just some of them
var table = CLITable(headers: headers, tableColor: .blue, textColor: .green)
or
var table = CLITable(headers: headers, tableColor: .blue)
or
var table = CLITable(headers: headers, textColor: .green)
dependencies: [
.package(
url: "https://github.com/heroesofcode/CLI-Table-Swift",
from: "1.0.0"
),
]
targets: [
.target(name: "MyApp"),
.testTarget(
name: "MyAppTests",
dependencies: [
"MyApp",
.product(name: "CLITable", package: "CLI-Table-Swift"),
]
)
]
To contribute, just fork this project and then open a pull request, feel free to contribute, bring ideas and raise any problem in the issue tab.
CLITable is released under the MIT license. See LICENSE for details.