Git Product home page Git Product logo

node-cli-box's Introduction

cli-box

cli-box

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

A library to generate ASCII boxes via NodeJS

cli-box

โ˜๏ธ Installation

$ npm i --save cli-box

๐Ÿ“‹ 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());

โ“ 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. ๐Ÿ›
  3. For direct and quick help, you can use Codementor. ๐Ÿš€

๐Ÿ“ 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.

๐Ÿ˜‹ How to contribute

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

๐Ÿ’– Support my projects

I open-source almost everything I can, and I try to reply 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 ๐Ÿš€

  • Buy me a bookโ€”I love books! I will remember you after years if you buy me one. ๐Ÿ˜ ๐Ÿ“–

  • PayPalโ€”You can make one-time donations via PayPal. I'll probably buy a coffee 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! โค๏ธ

๐Ÿ’ซ Where is this library used?

If you are using this library in one of your projects, add it in this list. โœจ

  • 3abnโ€”A 3ABN radio client in the terminal.
  • artstack-downloaderโ€”Download artworks from your following users.
  • ascii-githubโ€”GitHub CLI Client
  • cli-cal (by Falco Nogatz)โ€”Github-like calendar graph for the CLI
  • cli-gh-calโ€”GitHub like calendar graphs in command line.
  • cli-githubโ€”A fancy GitHub client for command line.
  • csk-cli (by Josh Max)โ€”A command-line client to ClearDarkSky.com, written in Node.js
  • ducksay-instant (by Kyle Graves)โ€”A rewrite of cowsay using the DuckDuckGo Instant Answer API
  • fluxmockserverapi (by Leo Cuello)โ€”Rest service flux-gal
  • ghcalโ€”See the GitHub contributions calendar of a user in the command line.
  • le-tableโ€”Another NodeJS module for creating ASCII tables.
  • overlapโ€”Overlap two strings that contain new lines. Useful for ASCII drawings.
  • text-animationโ€”Create beautiful ASCII text animations using NodeJS.

๐Ÿ“œ License

MIT ยฉ Ionicฤƒ Bizฤƒu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.