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

super-cli

v1.0.1

Published

Super-CLI is a micro framework for command line tools.

Downloads

15

Readme

Super-CLI

npm version Build Status Standard - JavaScript Style Guide

Super-CLI is a micro framework for creating command line tools in node. The goal with Super-CLI is to have a simple and powerful API, which enables you to create beautiful CLI programs with minimal effort.

A Super-CLI script will have a structure like below.

my-script command [options, ...] [arguments, ...]

Install

npm install super-cli -—save

Usage

To get started you have to require the super-cli module and register your commands. Remember to set the environment to node at the top of the script #!/usr/bin/env node and make your script executable chmod a+x my-script.

#!/usr/bin/env node

const SuperCLI = require('super-cli')

const cli = new SuperCLI()

cli.on('my-command', arg => {
  console.log(arg)
})

Register commands

Commands are simply registered like below and arguments are automatically parsed to the callbacks as function arguments. If your CLI program has a lot of commands, it would be a great idea to move the command callbacks into seperate files.

cli.on('my-command', (arg1, arg2, ...) => {
  // do something
})

Check for options

cli.option('-h', '--help') // will return true if set
cli.option('-l=', '--lastname=') // will return the value of --lastname if set

Run command

Trigger a command from within the script.

cli.run('my-command')

Prompt user for input

cli.prompt('My question:').then(answer => console.log(answer))

Catch all commands

This will run if no registered command was triggered.

cli.on('*', (...args) => {
  console.log(args)
})

Listen for data on stdin

cli.stdin(data => console.log(data))

Write data to stdout

// you can use
console.log('message')
// or
cli.stdout('message')

On exit

cli.on('exit', () => {
  // this event will fire on cli exit or termination
})

Exit cli

cli.exit() // will close the cli and fire the exit event