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

mclainsmt-cli-prompt

v1.0.3

Published

Synchronously interact with your users through their console/terminal with out the head-ache of asynchronous code calls. mclainsmt-cli-prompt provides a simple, one-function API for 'synchronously' prompting (questioning) a user through their console/ter

Downloads

30

Readme

mclainsmt-cli-prompt

A simple way to synchronously interact with your users through the command-line.

What is mclainsmt-cli-prompt ?

Synchronously interact with your users through the command-line with out the head-ache of asynchronous code calls.

mclainsmt-cli-prompt provides a simple, one-function API for 'synchronously' prompting (questioning) a user through the command-line, then reading in that user's input (answer).

With mclainsmt-cli-prompt, you'll be able to interact with your users through their console or terminal in a more natural (line-by-line) way.

Installation

> npm install mclainsmt-cli-prompt

API Examples

require("mclainsmt-cli-prompt") returns a function that takes a string argument (the prompt) and returns a string (the response/answer) typed by the user on the command line...

  • input: 'the prompt' [string type],
  • return: 'the user's response/answer' [string type]

Example 1: Let's prompt the user from the command-line for his/her full name...

const cliPrompt = require("mclainsmt-cli-prompt");

// let's prompt the user to enter each part of their name...

let firstName = cliPrompt("Enter your first name:");

let middleName = cliPrompt("Ennter your middle name:");

let lastName = cliPrompt("Enter you last name");

// String the full name together...

let fullName = `${firstName} ${middleName} ${lastName}`;

// Output 'fullName'

console.log("\nYour full name is: " + fullName);

Example 2: Prompt the user with a "Yes" or "No" question. If the user gives any answer except for "Yes" - loop back to the prompt (question).

const cliPrompt = require("mclainsmt-cli-prompt");

console.clear();

// Prompt the user repeatedly until they answer "Yes"...

while (cliPrompt("Is the Earth round? (Yes/No)").toUpperCase() != "YES") {

    console.log("\nWrong answer, please try again...");
}

// User answered "Yes"..

console.log("\nYOUR CORRECT!! :-)");

Unit Testing

mclainsmt-cli-prompt was designed, implemented, and tested on a Windows 10 machine, running Node v12.13.1.

We strongly suggest that you run the provided unit tests to make sure that every thing will work as expected for the platforms your targeting.

Make sure you install 'mocha' first...

// install mocha

> npm install --global mocha
// or as a development dependency within your project folder

> npm install --save-dev mocha
 // then run the test from the 'mclainsmt-cli-prompt' package folder 
 // within your project's 'node_modules' folder

> mocha test

Maintainer

Jeffery Chae Mclain (Founder & CEO of MclainSMT)