Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brendanashworth/cli-table
Draw tables in a command line interface. Just like MySQL.
https://github.com/brendanashworth/cli-table
Last synced: 9 days ago
JSON representation
Draw tables in a command line interface. Just like MySQL.
- Host: GitHub
- URL: https://github.com/brendanashworth/cli-table
- Owner: brendanashworth
- Created: 2014-09-12T22:04:48.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-12T23:55:31.000Z (about 10 years ago)
- Last Synced: 2023-04-10T02:50:01.195Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 107 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cli-table
> cli-table helps with drawing tables in command line interfaces.
# Usage
```java
TextTable table = new TextTable();
table.addRow("Name", "Age");
table.addBar();
table.addRow("Gracie Weber", 24);
table.addRow("Lexi O'Conner", 22);System.out.println(table.toString());
``````
+--------------+----+
|Name |Age |
+--------------+----+
|Gracie Weber |24 |
|Lexi O'Conner |22 |
+--------------+----+
```## Order by statement
```java
TextTable table = new TextTable();table.addRow("Name", "Age");
table.addBar();
table.addRow("Gracie Weber", 24);
table.addRow("Lexi O'Conner", 22);
table.orderBy(1, true); // order by first column, ascendingSystem.out.println(table.toString());
```~~~~
+--------------+----+
|Name |Age |
+--------------+----+
|Lexi O'Conner |22 |
|Gracie Weber |24 |
+--------------+----+
~~~~## Where statement
```java
TextTable table = new TextTable();table.addRow("Name", "Age");
table.addBar();
table.addRow("Gracie Weber", 24);
table.addRow("Lexi O'Conner", 22);
table.where(1, new WhereComparator() {
@Override
public boolean onCompare(Object colData) {
return (Integer) colData > 23;
}
});System.out.println(table.toString());
``````
+-------------+----+
|Name |Age |
+-------------+----+
|Gracie Weber |24 |
+-------------+----+
```