Socket
Socket
Sign inDemoInstall

slop

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    slop

Overly simple, c(S)ommand Line Options Parser.


Version published
Weekly downloads
1
Maintainers
1
Install size
9.47 kB
Created
Weekly downloads
 

Readme

Source

Slop

This module is meant to be an overly simple, c(S)ommand Line Options Parser.

Installation

npm install slop --save

Usage

/**
 * Module dependencies.
 */
var slop = require('slop');
/**
 * Process.argv will be an array.
 * Array:
 *  1st element will be 'node'
 *  2nd element will be '/path/to/this/JavaScript/file'
 *  3rd - Nth elements will be additional command line arguments
 *
 * Introspect Node arguments vector for:
 * - optional port to begin accepting connections
 *
 * Options.get() values may yield:
 * - {undefined}
 * - {boolean} true
 * - {string} (non-empty)
 *
 * Options.has() values may yield:
 * - {boolean} true
 * - {boolean} false
 */
var options = slop().parse(process.argv),
    port = options.get('port'),
    debug = options.has('debug');
/**
 * Default the Port value if it's not defined.
 */
port = (typeof port === 'string' && Number(port) >= 0) ? port : '8080';

if (debug) {
    console.log('------------------------------');
    console.log('Incoming Option Values.');
    console.log('Port: ' + port);
    console.log('------------------------------');
}

Tests

No unit tests are currently present. Eventually:

npm test

Contributing

In lieu of a formal style guideline, take care to maintain the existing coding style.

Release History

  • 0.0.1 Initial release

Keywords

FAQs

Last updated on 23 Mar 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc