@visulima/cerebro
Version:
A delightful toolkit for building cross-runtime CLIs for Node.js, Deno, and Bun.
66 lines (65 loc) • 2.48 kB
TypeScript
import type { Content as IContent } from "../../../types/command-line-usage.d.ts";
import BaseSection from "./base-section.d.ts";
/**
* A Content section comprises a header and one or more lines of content.
* @property header The section header, always bold and underlined.
* @property content Overloaded property, accepting data in one of four formats:
*
* 1. A single string (one line of text)
* 2. An array of strings (multiple lines of text)
* 3. An array of objects (recordset-style data). In this case, the data will be rendered in table format. The property names of each object are not important, so long as they are consistent throughout the array.
* 4. An object with two properties - `data` and `options`. In this case, the data and options will be passed directly to the underlying [table](https://github.com/visulima/visulima/tree/main/packages/tabular) module for rendering.
* @property raw - Set to true to avoid indentation and wrapping. Useful for banners.
* @example
* Simple string of content. For ansi formatting, use [colorize template literal syntax](https://github.com/visulima/visulima/tree/main/packages/colorize#tagged-template-literals).
* ```js
* {
* header: 'A typical app',
* content: 'Generates something {rgb(255,200,0).italic very {underline.bgRed important}}.'
* }
* ```
*
* An array of strings is interpreted as lines, to be joined by the system newline character.
* ```js
* {
* header: 'A typical app',
* content: [
* 'First line.',
* 'Second line.'
* ],
* }
* ```
*
* An array of arrays is rendered in table layout.
* ```js
* {
* header: 'A typical app',
* content: [
* [ 'First row, first column.', 'First row, second column.', ],
* [ 'Second row, first column.', 'Second row, second column.', ],
* ]
* }
* ```
*
* An object with `data` and `options` properties will be passed directly to the underlying [table](https://github.com/cli-table/cli-table3) module for rendering.
* ```js
* {
* header: 'A typical app',
* content: {
* data: [
* [ 'First row, first column.', 'First row, second column.', ],
* [ 'Second row, first column.', 'Second row, second column.', ],
* 'Second row, first column.',
* ],
* options: {
* colWidths: [80],
* }
* }
* }
* ```
*/
declare class ContentSection extends BaseSection {
constructor(section: IContent);
private getContentLines;
}
export default ContentSection;