cli-box
A library to generate ASCII boxes via NodeJS
Last updated 4 years ago by ionicabizau .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install cli-box 
SYNC missed versions from official npm registry.

cli-box

cli-box

Support me on Patreon Buy me a book PayPal Ask me anything Version Downloads Get help on Codementor

Buy Me A Coffee

A library to generate ASCII boxes via NodeJS

cli-box

:cloud: Installation

# Using npm
npm install --save cli-box

# Using yarn
yarn add cli-box

:clipboard: Example

// Dependencies
var Box = require("cli-box");

// Create a simple box
var b1 = Box("20x10");
console.log(b1.toString());

// Set custom marks
var b2 = new Box({
    w: 10
  , h: 10
  , stringify: false
  , marks: {
        nw: "╔"
      , n:  "══"
      , ne: "╗"
      , e:  "║"
      , se: "╝"
      , s:  "══"
      , sw: "╚"
      , w:  "║"
      , b: "░░"
    }
});
console.log(b2.stringify());


// Box with text and use the stringify
var b3 = 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);

// Box with aligned text to top-right
var b4 = Box("30x20", {
    text: "Box content"
  , stretch: true
  , autoEOL: true
  , vAlign: "top"
  , hAlign: "right"
});
console.log(b4);

// Full screen box
var b5 = Box({fullscreen: true, marks: {}}, "Hello World!");
console.log(b5.toString());

:question: Get Help

There are few ways to get help:

  1. Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
  2. For bug reports and feature requests, open issues. :bug:
  3. For direct and quick help, you can use Codementor. :rocket:

:memo: Documentation

CliBox(options, text)

Creates a new ASCII box.

Params

  • Object|String options: A string representing the size: WIDTHxHEIGHT (e.g. 10x20) or an object:

  • width or w (Number): The box width.

  • height or h (Number): The box height.

  • fullscreen (Boolean): If true, the box will have full size (default: false).

  • stringify (Boolean): If false the box will not be stringified (the CliBox object will be returned instead).

  • 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|Stringify The CliBox object (if options.stringify is false) or the stringified box.

stringify()

Returns the stringified box.

Return

  • String Stringified box string.

:yum: How to contribute

Have an idea? Found a bug? See how to contribute.

:sparkling_heart: Support my projects

I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications for free! You can even change the source code and redistribute (even resell it).

However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:

  • Starring and sharing the projects you like :rocket:

  • Buy me a book—I love books! I will remember you after years if you buy me one. :grin: :book:

  • PayPal—You can make one-time donations via PayPal. I'll probably buy a coffee tea. :tea:

  • Support me on Patreon—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).

  • Bitcoin—You can send me bitcoins at this address (or scanning the code below): 1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6

Thanks! :heart:

:dizzy: Where is this library used?

If you are using this library in one of your projects, add it in this list. :sparkles:

  • le-table
  • overlap
  • cli-gh-cal
  • text-animation
  • cli-cal
  • ghcal
  • ducksay-instant
  • ascii-github
  • csk-cli
  • fluxmockserverapi
  • survivio
  • gem-mine
  • bhedge
  • gafas
  • short-fire
  • oversize-images-finder
  • image-oversize-finder
  • @gem-mine/sapphire
  • expo-library
  • @gofynd/fdk-cli
  • 3abn
  • cli-github
  • artstack-downloader

:scroll: License

MIT © Ionică Bizău

Current Tags

  • 6.0.10                                ...           latest (4 years ago)

23 Versions

  • 6.0.10                                ...           4 years ago
  • 6.0.9                                ...           6 years ago
  • 6.0.8                                ...           7 years ago
  • 6.0.7                                ...           8 years ago
  • 6.0.6                                ...           8 years ago
  • 6.0.5                                ...           8 years ago
  • 6.0.4                                ...           8 years ago
  • 6.0.3                                ...           8 years ago
  • 6.0.2                                ...           8 years ago
  • 6.0.1                                ...           9 years ago
  • 6.0.0                                ...           9 years ago
  • 5.2.1                                ...           9 years ago
  • 5.2.0                                ...           9 years ago
  • 5.1.0                                ...           9 years ago
  • 5.0.0                                ...           9 years ago
  • 4.0.0                                ...           9 years ago
  • 3.0.0                                ...           9 years ago
  • 2.1.1                                ...           10 years ago
  • 2.0.1                                ...           10 years ago
  • 2.0.0                                ...           10 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 1
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (5)
Dev Dependencies (0)
None
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE