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

list-selector-cli

v0.0.3

Published

(Hopefully) useful little commandline interface for selecting items from a list, inspired by the git-add interactive interface.

Downloads

84

Readme

Git-style interactive list selector for Node CLI apps

  • Does one thing: Lets the users of your NodeJS app interactively select/de-select items from a list by indices and ranges on the commandline.

  • Familiar "UI" -- to GitHubbers at least! Same interface as the trusty "git add --interactive"

  • Brain-dead simple to use in your project

  • Options can be any array of toString-able things

  • Get the user's response in a callback OR a jQuery-style promise

Example: Let's make a sandwich

Probably better for selecting filepaths, but I'm hungry right now so...

Let's choose the toppings on your sandwich via CLI.

What you do

  1. Install from NPM:
npm install list-selector-cli`
  1. Require it in your project:
var cliselect = require("list-selector-cli");
  1. Pick an array of options:
var options = ["lettuce", "tomatoes", "spinach", "ham"];
  1. Create your list:
var sandwichChoice = new cliselect(options);
  1. Prompt the user: console.log("What would you like on your sandwich?")

  2. Let them interactively choose their options and handle their response

  • In a callback:
sandwichChoice.prompt(function(selection) { /** do something **/ });
  • Or with a promise:
var promise = sandwichChoice.prompt();
promise.done(function(selection) { /** do something **/ });

What you get

$ node examples/sandwich.js
What would you like on your sandwich?

 0:  lettuce
 1:  tomatoes
 2:  spinach
 3:  avocado
 4:  ham
 5:  bacon
 6:  oil
 7:  vinegar

Update selection (blank to accept)>>: 

Hmm... All the veggies and some oil, please.

Update selection (blank to accept)>>: 0-4,6
*0:  lettuce
*1:  tomatoes
*2:  spinach
*3:  avocado
*4:  ham
 5:  bacon
*6:  oil
 7:  vinegar
Update selection (blank to accept)>>:

Crap, I don't eat ham. De-ham the sandwich, plz.

Update selection (blank to accept)>>:-4
-4
*0:  lettuce
*1:  tomatoes
*2:  spinach
*3:  avocado
 4:  ham
 5:  bacon
*6:  oil
 7:  vinegar
Update selection (blank to accept)>>:

Eat-able? Yes. <Enter>

[ 'lettuce', 'tomatoes', 'spinach', 'avocado', 'oil' ]

Totally pitching a commandline interface to Subway...

Maybe ssh.subway.com: "open 8am to 9pm and 24 hrs a day on port 22..." :-)