### Deno/ESM CLI UI Layout Example Source: https://github.com/yargs/cliui/blob/master/README.md Provides an example of using cliui in a Deno or ESM environment. It mirrors the basic layout example but uses ES module imports for cliui and chalk. ```typescript import cliui from "cliui"; import chalk from "chalk"; // Deno: import cliui from "https://deno.land/x/cliui/deno.ts"; const ui = cliui({}) ui.div('Usage: $0 [command] [options]') ui.div({ text: 'Options:', padding: [2, 0, 1, 0] }) ui.div( { text: "-f, --file", width: 20, padding: [0, 4, 0, 4] }, { text: "the file to load." + chalk.green("(if this description is long it wraps).") , width: 20 }, { text: chalk.red("[required]"), align: 'right' } ) console.log(ui.toString()) ``` -------------------------------- ### Basic CLI UI Layout Example Source: https://github.com/yargs/cliui/blob/master/README.md Demonstrates creating a basic command-line interface layout using cliui. It includes a usage line, an options header, and a formatted option with a description and a required tag, utilizing chalk for coloring. ```javascript const ui = require('cliui')() const {Chalk} = require('chalk'); const chalk = new Chalk(); ui.div('Usage: $0 [command] [options]') ui.div({ text: 'Options:', padding: [2, 0, 1, 0] }) ui.div( { text: "-f, --file", width: 20, padding: [0, 4, 0, 4] }, { text: "the file to load." + chalk.green("(if this description is long it wraps).") , width: 20 }, { text: chalk.red("[required]"), align: 'right' } ) console.log(ui.toString()) ``` -------------------------------- ### Install cliui and chalk Source: https://github.com/yargs/cliui/blob/master/README.md Installs the latest versions of cliui and chalk using npm. Chalk is often used with cliui for colored output. ```bash npm i cliui@latest chalk@latest ``` -------------------------------- ### Layout DSL Output Example Source: https://github.com/yargs/cliui/blob/master/README.md The expected shell output from the Layout DSL example, showing how newlines and tabs are interpreted to create a structured, multi-column display. ```shell Usage: node ./bin/foo.js provide a regex provide a glob [required] ``` -------------------------------- ### Layout DSL with Newlines and Tabs Source: https://github.com/yargs/cliui/blob/master/README.md Illustrates cliui's Layout DSL where newline (\n) creates new rows, tab (\t) creates new columns, and space (\s) creates padding within a single div call. This example formats usage instructions with arguments and requirements. ```javascript var ui = require('./')({ width: 60 }) ui.div( 'Usage: node ./bin/foo.js\n' + ' \t provide a regex\n' + ' \t provide a glob\t [required]' ) console.log(ui.toString()) ``` -------------------------------- ### cliui API Documentation Source: https://github.com/yargs/cliui/blob/master/README.md Documentation for the cliui constructor and its core methods for building command-line interfaces. Covers initialization options and methods for structuring output. ```APIDOC cliui({width: integer, wrap: boolean}) Initializes a new cliui instance. - width: Specify the maximum width of the UI. Defaults to the current window width or 80 if detection fails. - wrap: Enable or disable the wrapping of text within columns. Defaults to true. cliui.div(column, column, ...) Creates a row with one or more columns. A column can be a string or an object with the following properties: - text: The content of the column. - width: The fixed width of the column. - align: Alignment of the text ('right' or 'center'). - padding: An array [top, right, bottom, left] for padding around the text. - border: Boolean, whether to draw a border around the column. cliui.span(column, column, ...) Similar to `div`, but the next row will be appended without creating a new line, allowing for continuous layout. cliui.resetOutput() Resets the UI elements of the current cliui instance, preserving the `width` and `wrap` settings. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.