sio-terminaltopbar

1.0.0 • Public • Published

SIO-TerminalTopBar - Inquirer

Build Status

Full presentation code

Full code Full inquirer

        inquirer.topBar.title=`
 $$$$$$   $$$$$$   $$$$$$
$$    $$    $$    $$    $$
$$          $$    $$    $$
$$$$$$      $$    $$    $$
     $$     $$    $$    $$
$$   $$     $$    $$    $$
$$$$$$    $$$$$$   $$$$$$ 
    `;
        inquirer.topBar.render();
        topBar.log("Hello world");
        topBar.error("Error 404");
        topBar.info("Very important info");
        topBar.warn("I can make warns");
        topBar.log("If i have more than 7 lines I can be scrolled");
        topBar.warn("And my borders changes dinamically to adapt to the user interactions");
        topBar.log("So i'm line 7");
        topBar.warn("And i'm line 8");

Creates a visual top bar and ASCII icon hero for your terminal project.

  • Gets well with inquirer
  • Make your terminal more atractive
  • Easy to use
  • You can travel the logs history with CTRL and the Down and Up keys.
  • The border updates on your actions to give you visible information.

Background

Using inquirer proves to be a good option for full terminal aplications but inquirer doesn't play very well with another console write options.

Sometimes you require to log very well visible and gratefull to see logs to your users.

Installation

SIO-TerminalTopBar was tested on Node.js v14+.

Install the package in your current project to start using it.

$ npm install sio-terminaltopbar

Without inquirer:

const topBar=require("sio-terminaltopbar");
topBar.render();

With inquirer (This lets you onli require inquirer into another modules and SIO-TerminalTopBar will be included as well):

//Modulo inicial
const topBar=require("sio-terminaltopbar");
const inquirer=require("inquirer");
inquirer.topBar.render();
inquirer.topBar.log("Inside start module");

//Any other module
const inquirer=require("inquirer");
inquirer.topBar.log("Inside any other module, inquirer has already","SIO-TerminalTopBar included");

Methods and attributes

All examples will be made without inquirer. If you are using it with the inquirer method just add "inquirer." before all the topBar calls.

Attributes

Title:

Use this attribute to print something on top of the SIO-TerminalTopBar

topBar.title=`
     $$$$$$   $$$$$$   $$$$$$
    $$    $$    $$    $$    $$
    $$          $$    $$    $$
    $$$$$$      $$    $$    $$
         $$     $$    $$    $$ 
    $$   $$     $$    $$    $$ 
    $$$$$$    $$$$$$   $$$$$$  
`;
topBar.render();

Result: SIO-TerminalTopBar.title

Methods

Render -> render():

Makes the top bar to update it's render, it is used mostly by the module but its required when you start the app that contains it.

topBar.render();
Log -> log(...args):

Prints a log inside the SIO-TerminalTopBar.

topBar.log("Hello world");
topBar.log("Can have","multiple arguments");
tobBar.log({inclusive:"objects"},["and","arrays"]);

SIO-TerminalTopBar.log

Error -> error(...args):

Prints an error inside the SIO-TerminalTopBar.

topBar.error("Hello world");
topBar.error("Can have","multiple arguments");
tobBar.error({inclusive:"objects"},["and","arrays"]);

SIO-TerminalTopBar.log

Warn -> warn(...args):

Prints a warn inside the SIO-TerminalTopBar.

topBar.warn("Hello world");
topBar.warn("Can have","multiple arguments");
tobBar.warn({inclusive:"objects"},["and","arrays"]);

SIO-TerminalTopBar.log

Info -> info(...args):

Prints an info inside the SIO-TerminalTopBar.

topBar.info("Hello world");
topBar.info("Can have","multiple arguments");
tobBar.info({inclusive:"objects"},["and","arrays"]);

SIO-TerminalTopBar.log

Clear -> clear():

Adds empty spaces to the SIO-TerminalTopBar to make the next log see visible by his own. Its important to notice that this doesn't erase the lines of the topBar, this means you can press CTRL + Up to go back on the log history.

topBar.log("Hello world");
topBar.clear();
tobBar.info("Only i'm visible. See how the top margin of the SIO-TerminalTopBar changes.","That means that you can press CTRL + UP[arrow key up] to view old logs");

SIO-TerminalTopBar.log

Clean -> clean():

Deletes all history logs and renders an empty SIO-TerminalTopBar.

topBar.log("Hello world");
topBar.error("I'm gonna be erased in a second","If that's not an error what could be one.");
topBar.clean();

SIO-TerminalTopBar.log

Todos

  • If text is bigger than the screen it shows ellipsis, so add right and left key funcionality.
  • Let the user define the height and width size of the topBar.
  • Without inquirer get the last cursor pos to return to it once topBar is rendered, it may fail with some user uses cases.

License

ISC

Readme

Keywords

Package Sidebar

Install

npm i sio-terminaltopbar

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

49.2 kB

Total Files

12

Last publish

Collaborators

  • empirreamm