https://github.com/brendanashworth/cli-table
Draw tables in a command line interface. Just like MySQL.
https://github.com/brendanashworth/cli-table
Last synced: 5 months 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 (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-09-12T23:55:31.000Z (almost 11 years ago)
- Last Synced: 2024-12-27T00:23:49.907Z (6 months ago)
- Language: Java
- Homepage:
- Size: 107 KB
- Stars: 1
- Watchers: 3
- 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 |
+-------------+----+
```