Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heroesofcode/cli-table-swift
Build Table for command line tools for macOS written in Swift
https://github.com/heroesofcode/cli-table-swift
Last synced: 1 day ago
JSON representation
Build Table for command line tools for macOS written in Swift
- Host: GitHub
- URL: https://github.com/heroesofcode/cli-table-swift
- Owner: heroesofcode
- License: mit
- Created: 2024-06-20T21:54:58.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-12T02:46:38.000Z (about 2 months ago)
- Last Synced: 2024-10-31T12:40:42.193Z (6 days ago)
- Language: Swift
- Homepage:
- Size: 682 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT
Awesome Lists containing this project
README
## CLI-Table-Swift
[![CI](https://github.com/heroesofcode/CLI-Table-Swift/actions/workflows/CI.yml/badge.svg)](https://github.com/heroesofcode/CLI-Table-Swift/actions/workflows/CI.yml)
[![codecov](https://codecov.io/gh/heroesofcode/CLI-Table-Swift/graph/badge.svg?token=DRwwBttVQh)](https://codecov.io/gh/heroesofcode/CLI-Table-Swift)
![GitHub Release](https://img.shields.io/github/v/release/heroesofcode/CLI-Table-Swift)
[![Platform Compatibility](https://img.shields.io/badge/Platforms-%20macOS%20-orange)]()
[![GitHub License](https://img.shields.io/github/license/heroesofcode/CLI-Table-Swift)](https://github.com/heroesofcode/CLI-Table-Swift/blob/main/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
```swift
import CLITablelet 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
```swift
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
```swift
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
```swift
dependencies: [
.package(
url: "https://github.com/heroesofcode/CLI-Table-Swift",
from: "1.1.0"
),
]
``````swift
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](https://github.com/heroesofcode/CLI-Table-Swift/blob/main/LICENSE) for details.