Package Exports
- cli-box
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cli-box) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
cli-box 
A library to generate ASCII boxes via NodeJS
Installation
$ npm i cli-box
Example
// Dependencies
var Box = require("cli-box");
// Create a simple box
var b1 = new Box("20x10");
console.log(b1.toString());
// Set custom marks
var b2 = new Box({
w: 10
, h: 10
, marks: {
nw: "╔"
, n: "══"
, ne: "╗"
, e: "║"
, se: "╝"
, s: "══"
, sw: "╚"
, w: "║"
, b: "░░"
}
});
console.log(b2.toString());
// Box with text
var b3 = new Box("20x10", "I will be \u001b[31mdis\u001b[0mplayed inside! \n A\u001b[34mnd I'm in a\u001b[0m new line!");
console.log(b3.toString());
// Box with aligned text to top-right
var b4 = new Box("30x20", {
text: "Box content"
, stretch: true
, autoEOL: true
, vAlign: "top"
, hAlign: "right"
});
console.log(b4.toString());
// Full screen box
var b5 = new Box({fullscreen: true, marks: {}}, "Hello World!");
console.log(b5.toString());
Documentation
CliBox(options, text)
Creates a new instance of CliBox function.
Params
- Object|String
options
: A string representing the size:WIDTHxHEIGHT
(e.g.10x20
) or an object: width
orw
(Number): The box width.height
orh
(Number): The box height.fullscreen
(Boolean): Iftrue
, the box will have full size (default:false
).marks
(Object): An object containing mark characters. Default:nw
:"+"
n
:"-"
ne
:"+"
e
:"|"
se
:"+"
s
:"-"
sw
:"+"
w
:"|"
b
:" "
- Object|String
text
: A string to be displayed or an object: text
(String): The text to be displayed.stretch
(Boolean): Stretch box to fix text (default:false
).autoEOL
(Boolean): Break lines automatically (default:false
).hAlign
(String): Horizontal alignement (default:"middle"
). It can take one of the values:"left"
,"middle"
,"right"
.vAlign
(String): Vertical alignement (default:"center"
). It can take one of the values:"top"
,"center"
,"bottom"
.
Return
- Object The
CliBox
instance.
toString()
Returns the stringified box.
Return
- String Stringified box string.
How to contribute
Have an idea? Found a bug? See how to contribute.
License
KINDLY © Ionică Bizău–The LICENSE file contains a copy of the license.