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

furious

v0.2.1

Published

Develop command line tools furiously

Downloads

2

Readme

Meet furious - commander inspired elegant solution for creating command line tools.

Build Status

furious is ultra lightweight and less than 100 lines of code. The API is dead simple and have been modified from commander to make few things simpler.

Installation

npm install furious --save

API

furious

var furious = require('furious');
//add commands and options here 
furious.execute(process.argv , 'Tool for doing string operations'); //execute the user given command.  

NOTE : Don't forget to call furious.execute() at the end. It is responsible for executing the user command.

.command(commandName , description , callback)

Create a command with this function.

  • commandName string - Command Name.
  • decription string - Description for the Command.
  • callback function(args) - function to be executed when command is given in the command line. args - array of arguments.
  • Example : programname upper hello - Here upper is the Command name and hello is available in args of the callback.
furious
  .command('upper' , 'print upper case values' , function(args){
    var firstArg = args[0];
    console.log(firstArg.toUpperCase());
  });

.option(optionNamesArray , description , callback)

Create options for already existing command.

  • optionNamesArray array - Option names. Each option name should start with - or --
  • description array - Description about the Option.
  • callback function(args) - function to be executed when option is given in the command line. args - array of arguments.
  • Example : programname upper -h - Here upper is Command name and -h is the option.
furious
  .command('upper' , 'print upper case values' , function(args){
    var firstArg = args[0];
    console.log(firstArg.toUpperCase());
  })
  .option(['-h' ,'--help'] , 'Help for Upper' , function(args){
    console.log('You can provide help for this command here.');
  });

In this case ,both programname upper -h and programname upper --help invoke the same callback.

.alias( aliasArray )

Specify Alias for commands.

furious
  .command('upper' , 'print upper case values' , function(args){
    var firstArg = args[0];
    console.log(firstArg.toUpperCase());
  })
  .alias(['up' , 'u']);

.execute(argv , description , noCommandOrOptionOperation , commonOperation)

This is where the user given command on the terminal is parsed and executed.

  • argv array - send in process.argv to execute the command given by user.
  • description string - Description of the command line tool.
  • noCommandOrOptionOperation function() - function to be executed when there is no commands given by user or the command definition is not available.
  • commonOperation function(argv) - function to be executed commonly for all the commands. Eg. You may instantiate timers for measuring the performance of your utility here.
var noCommandOrOptionOperation = function(){ console.log('Please Specify a Command or Option'); };
var commonOperation = function(argv){console.log('Welcome to the cli');};

furious.execute(process.argv , 'Cli for something' , noCommandOrOptionOperation , commonOperation );

Expect for a printHelp function in future versions , that can be easily used in noCommandOrOptionOperation and commonOperation.

Caveats

  • If definition for a command is specified twice then , first definition will be considered and rest are rejected.
  • The package is in beta phase and has few things left behind to do. So watch out for version 1.0.0 , until then , try to play around with it.

Contribution

More than welcomed. Feel free to send in a pull request or file an issue.

License

The MIT License.