heroesofcode/cli-table-swift
## CLI-Table-Swift
CLI-Table-Swift
[[CI]](https://github.com/heroesofcode/CLI-Table-Swift/actions/workflows/CI.yml) [[codecov]](https://codecov.io/gh/heroesofcode/CLI-Table-Swift) [GitHub Release] [[Platform Compatibility]]() [[GitHub License]](https://github.com/heroesofcode/CLI-Table-Swift/blob/main/LICENSE)
Build Table for command line tools for macOS written in Swift
<img src="https://github.com/heroesofcode/CLI-Table-Swift/blob/main/assets/example.gif?raw=true">
┌─────────┬─────┬────────────────┐
│ Name │ Age │ City │
├─────────┼─────┼────────────────┤
│ Matheus │ 23 │ São Paulo │
├─────────┼─────┼────────────────┤
│ Alice │ 30 │ Rio de Janeiro │
└─────────┴─────┴────────────────┘Usage
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)
var table = CLITable(headers: headers, tableColor: .hex("#FF5733"), textColor: .hex("#2ECC71"))
or
var table = CLITable(headers: headers, tableColor: .blue)
var table = CLITable(headers: headers, tableColor: .hex("#FF5733"))
or
var table = CLITable(headers: headers, textColor: .green)
var table = CLITable(headers: headers, textColor: .hex("#2ECC71"))Installing
dependencies: [
.package(
url: "https://github.com/heroesofcode/CLI-Table-Swift",
from: "1.1.0"
),
]targets: [
.target(name: "MyApp"),
.testTarget(
name: "MyAppTests",
dependencies: [
"MyApp",
.product(name: "CLITable", package: "CLI-Table-Swift"),
]
)
]Contributing
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.
License
CLITable is released under the MIT license. See LICENSE for details.
Package Metadata
Repository: heroesofcode/cli-table-swift
Default branch: main
README: README.md