cliui
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
string-width | 4.2.3 | 2.33 kB | MIT | prod | |
strip-ansi | 6.0.1 | 1.99 kB | MIT | prod | |
wrap-ansi | 7.0.0 | 4.22 kB | MIT | prod |
Cliui is a Node.js package designed to easily create complex multi-column command-line-interfaces. It provides a simple and effective way to manage the layout of your command-line tool's UI, including creating rows with multiple columns, manipulating text width and alignment, and even managing padding and bordering. It exposes a simple layout DSL for column and row creation and supports the interpretation of '\n', '\t', and '\s' characters as new rows, new columns, and padding, respectively.
To utilize cliui, begin by installing it via npm:
npm install cliui
Then, in your JavaScript file, require it and create a new instance:
const ui = require('cliui')()
Next, you can start building your interface using the div method:
ui.div('Usage: $0 [command] [options]')
You can then create multiple columns inside your row using object objects:
ui.div(
{
text: "-f, --file",
width: 20,
padding: [0, 4, 0, 4]
},
{
text: "the file to load."
},
{
text: "required",
align: 'right'
}
)
Finally, output the UI as a string to display it:
console.log(ui.toString())
For a full reference of the available functions and their usage, look at the Methods Section in the readme.
The cliui documentation is available directly within the readme file of the official GitHub repository, https://github.com/yargs/cliui. Here, you'll find detailed usage examples, method explanations, different object options for text width, padding, and alignment manipulation, and much more. Follow the link to access and learn more about effectively utilizing cliui in your projects.