CLITable

1.1.0

Build Table for command line tools for macOS written in Swift
heroesofcode/CLI-Table-Swift

What's New

1.1.0

2024-09-12T02:46:38Z

What's changed

It is now possible to add colors provided by the framework and also add them by hexadecimal, see the example below:

var table = CLITable(headers: headers, tableColor: .blue, textColor: .green)
var table = CLITable(headers: headers, tableColor: .hex("#FF5733"), textColor: .hex("#2ECC71"))

Full Changelog: 1.0.0...1.1.0

CLI-Table-Swift

CI codecov GitHub Release Platform Compatibility GitHub License

Build Table for command line tools for macOS written in Swift

┌─────────┬─────┬────────────────┐
│ 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.

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

Last updated: Wed May 14 2025 17:41:38 GMT-0900 (Hawaii-Aleutian Daylight Time)