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

arghandle

v0.0.4

Published

library to parse commandline-args and options.

Downloads

9

Readme

argHandle Build Status

Library to parse commandline-args and options.

Usage

##Install

npm install arghandle

##Implementation Require this module into your project

var arghandle = require('arghandle'),
    handle = new arghandle();

    handle.process();

You can test this by running

node yourscript.js --help

This is a reserved keyword. This will show all the handelers that have been defined

###Defining custom argument handlers A handler object should be designed like the following:

{
    keys: ['--port', '-P'], // e.g. node script.js [--port|-P] 8080
    method: function (self) {
        console.log(self.getNext()); // 8080
    },
    description: 'Set application listning port'
}

Their are three methods to append your argument handlers. ####Initially declaring the options

var handle = new arghandle({
    // This defines the start point for arguments to get processed
    startIndex: 5,
    // This defines the custom argument handlers
    definedArgs: [
        {
            keys: ['--yes-debug', '-D'],
            method: function (self) {
                appConfig.debug = true;
            },
            description: 'Set application to debug'
        },
        {
            keys: ['--port', '-P'],
            method: function (self) {
                appConfig.port = self.getNext();
            },
            description: 'Set application listning port'
        }
    ],
    // This defines arguments passed by the command line
    argv: process.argv
}); 

####Concating an array of handlers

var appConfig = {
    debug: false,
    port: 8080,
    hostname: 'localhost'
};

handle.concat([
    {
        keys: ['--debug', '-D'],
        method: function (self) {
            appConfig.debug = true;
        },
        description: 'Set application to debug'
    },
    {
        keys: ['--port', '-P'],
        method: function (self) {
            appConfig.port = self.getNext();
        },
        description: 'Set application listning port'
    }
]);

####Appending a single handler

handle.push({
    keys: ['--hostname', '-H'],
    method: function (self) {
        appConfig.hostname = self.getNext();
    },
    description: 'Set application listning hostname'
});

####Defining the start position for arguments This is declared in the initial method. This is done as follows...

var handle = new arghandle({
    startIndex: 2
});

###Processing the arguments This is done by calling the method as follows...

handle.process(process.argv); // if argv is not declared in the initial method
handle.process(); // if argv was included in the initial method

This will return false if an undefined argument is sent