Skip to content

Build Table for command line tools for macOS written in Swift

License

Notifications You must be signed in to change notification settings

heroesofcode/CLI-Table-Swift

Repository files navigation

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.

About

Build Table for command line tools for macOS written in Swift

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages