scicli

1.3.5 • Public • Published

SciCLI

Library for interactive promise-based CLI

Usage

/**
 * This test is for basic command handling
 */

//Import scicli
const scicli = require("scicli");

//Create instance
const inst = new scicli();

//Add `exit` command
inst.addCommand("exit", async args => {
  //Occures when `exit` command is executed
  var reason = args.join(" "); //Join all of the arguments into a string, using a space as the seperator of each element
  if (!reason) {
    //Stop requesting input
    inst.stopInput();

    //If no reason provided, show exit message using `alert`
    inst.alert("Exitting without reason...");
    process.exit();
    return;
  }

  //Stop requesting input
  inst.stopInput();

  //If reason provided, show exit message using `info`
  inst.info("Exitting because `" + reason + "`");
  process.exit();
});

//Show welcome message using `success` & `info`
inst.success("Welcome to SciCLI Basic Test");
inst.info("Available Commands: Exit");

//Start requesting input
inst.startInput();

Readme

Keywords

none

Package Sidebar

Install

npm i scicli

Weekly Downloads

1

Version

1.3.5

License

MIT

Unpacked Size

25 kB

Total Files

11

Last publish

Collaborators

  • theosofficial