To use a custom border for your tables simply create a struct conforming to the Border protocol and pass it as part of a custom Configuration. For example:
import Table
struct CustomBorder: Border {
public let topBody = "─"
public let topJoin = "┬"
public let topLeft = "┌"
public let topRight = "┐"
public let bottomBody = "─"
public let bottomJoin = "┴"
public let bottomLeft = "└"
public let bottomRight = "┘"
public let bodyLeft = "│"
public let bodyRight = "│"
public let bodyJoin = "│"
public let joinBody = "─"
public let joinLeft = "├"
public let joinRight = "┤"
public let joinJoin = "┼"
}
func doSomething() throws -> String {
…
let configuration = Configuration(border: CustomBorder(), columns: columns)
return try Table(data: data).table()
}
Licence
Table is released under the MIT license. See LICENSE for details.
Swift Tables
Working on CLI tools in Swift? Need to display tables? Continue reading.
Add the dependency to your
Package.swift
file:Basic Usage
Results in a pretty table:
Alignment
You can align your table rows by passing in a
Configuration
:Results in:
Padding
The
Configuration
also allows for padding:Would give you:
Custom Border Style
To use a custom border for your tables simply create a
struct
conforming to theBorder
protocol and pass it as part of a customConfiguration
. For example:Licence
Table is released under the MIT license. See LICENSE for details.