CLITable

1.0.0

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

What's New

Initial release

2024-06-21T03:56:50Z
  • Initial release

Check the documentation

CLI-Table-Swift

CI 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)

or

var table = CLITable(headers: headers, tableColor: .blue)

or

var table = CLITable(headers: headers, textColor: .green)

Installing

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"),
    ]
  )
]

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

  • None
Last updated: Sun Jul 07 2024 02:42:43 GMT-0900 (Hawaii-Aleutian Daylight Time)