OutputUI
The OutputUI class provides methods for rendering formatted and styled console output, including titles, lists, and tables.
Example
const outputUI = new OutputUI(output);
outputUI.title('My Title');
outputUI.list(['Item 1', 'Item 2']);
const table = outputUI.createTable({ border: 'single' });
table.push(['Row 1', 'Row 2']);
console.log(table.toString());Constructors
new OutputUI()
new OutputUI(output): OutputUICreates an instance of OutputUI.
Parameters
| Parameter | Type | Description |
|---|---|---|
| The |
Returns
Example
const outputUI = new OutputUI(output);Properties
| Property | Modifier | Type | Default value | Description |
|---|---|---|---|---|
|
| The available border styles. | ||
| ( |
| The ora spinner instance. | |
|
|
| The table constructor. |
Methods
createTable()
createTable(options?): TableCreates a table with the specified options.
Parameters
| Parameter | Type | Description |
|---|---|---|
| The options for creating the table. |
Returns
Table
The created table instance.
Example
const table = outputUI.createTable({ border: 'single' });
table.push(['Row 1', 'Row 2']);
console.log(table.toString());list()
list(items, _options?): voidRenders a list with the specified items and options.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The list items to render. |
| The options for rendering the list. |
Returns
void
Example
outputUI.list(['Item 1', 'Item 2'], { title: 'My List', border: 'single' });size()
size(): TerminalSizeGets the current terminal size.
Returns
TerminalSize
The current terminal size.
Example
const size = outputUI.size();
console.log(`Width: ${size.columns}, Height: ${size.rows}`);table()
table(rows, options?): stringRenders a table with the specified rows and options.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The rows to render in the table. |
| The options for rendering the table. |
Returns
string
The rendered table as a string.
Example
const table = outputUI.table([['Row 1', 'Row 2']], { border: 'single' });
console.log(table);title()
title(text, _options?): voidRenders a title with the specified options.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The title text to render. |
| The options for rendering the title. |
Returns
void
Example
outputUI.title('My Title', { border: 'double', padding: 4 });