npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lczpln/ncli

v1.1.5

Published

A command-line interface utility that provides various methods for interacting with the terminal.

Downloads

4

Readme

NCLI

A command-line interface utility that provides various methods for interacting with the terminal.

Install

yarn add @lczpln/ncli

or

npm install @lczpln/ncli --save

Usage

Initializes the NCLI class and sets up the required dependencies.

import ncli from "@lczpln/ncli";

const ncli = new NCLI();

Parameters

  • titleColor: the color to use for the title text (default: "blue").
  • subtitleColor: the color to use for the subtitle text (default: "whiteBright").
  • msgColor: the color to use for message text (default: "whiteBright").
  • optionsColor: the color to use for options text (default: "green").
  • inputCharColor: the color to use for input characters (default: "blue").

All the parameters are optional and have default values. You can check all colors available here: https://github.com/chalk/chalk#colors

Methods

getUserInput(options)

Asynchronously prompts the user for input and returns the user's choice.

Example

const ncli = new NCLI();

const options = [
  { title: "Apple", action: (input) => input },
  { title: "Banana", action: (input) => input },
  { title: "Orange", action: (input) => input },
  { title: "Watermelon", action: (input) => input },
];

const fruitChosen = await ncli.getUserInput({
  title: "FRUIT SELECTION",
  subtitle: "Select your favority fruit",
  options,
});

const fruit = options[fruitChosen - 1].title;

// > 2

console.log(fruit); // Banana

alt text

or

const ncli = new NCLI();

const name = await ncli.getUserInput({
  title: "NAME SELECTION",
  subtitle: "What's your name?",
  action: (input) => input,
});

// > World

console.log("Hello " + name + "!"); // Hello World!

alt text

Parameters

  • options: an object that contains the following properties:
    • title: the title to be displayed on the terminal.
    • subtitle: the subtitle to be displayed on the terminal.
    • image: an object that contains the following properties:
      • path: the path to the image file.
      • process: a boolean flag indicating whether the image should be processed or not.
      • width: width of the image in terminal.
      • height: height of the image in terminal.
      • preserveAspectRatio: a flag indicating whether the aspect ratio of the image should be preserved or not.
    • action: a function that will be called after the user input is received.
    • error: a boolean flag indicating whether an error message should be displayed.
    • options: an array of objects that represent the options that the user can choose from.
      • title: options title to be displayed like this: 1) myTitle
      • action action to be dispatched after user input a valid option number
    • noClear: a boolean flag indicating whether the terminal should be cleared before displaying the prompt.

The _clear is used to clear the terminal if noClear is false.

log()

Displays a message on the terminal.

Example

ncli.log({ msg: "Searching for user" });

//await searchUsers()

Parameters

  • title: the title to display before the message (default: null)
  • msg: the message to be displayed on the terminal (required)
  • color: the color to use for the message text (default: "whiteBright").
  • noClear: boolean value indicating if the terminal should be cleared before displaying the message (default: false).

The _clear is used to clear the terminal if noClear is false.

waitForKey(message)

Asynchronously waits for the user to press any key on the keyboard.

Example

await ncli.waitForKey({});

or

await ncli.waitForKey({ msg: "My awesome msg! Please press enter (:" });

Parameters

  • title: the title to display before the message (default: null)
  • msg: the message to be displayed on the terminal (required)
  • color: the color to use for the message text (default: "whiteBright").
  • noClear: boolean value indicating if the terminal should be cleared before displaying the message (default: false).

The _clear is used to clear the terminal if noClear is false.