Socket
Book a DemoInstallSign in
Socket

parse-argsv

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-argsv

A simple and reliable Node.js command-line arguments parser

0.9.18
latest
npmnpm
Version published
Maintainers
1
Created
Source

ArgvParser

A simple Node.js command-line arguments parser.

Note #1 This module can be used with any existing version of node.js and npm.

How to install the module:

By using npmjs.org:

 npm install parse-argsv --global --save 

 npm install parse-argsv --save 

How to use the parse-argsv module installed:

Parsing Node.js command-line arguments


'use strict'
 
var ArgsParser = require('parse-argsv');

var argsv = new ArgsParser();

// Retrieve an array of command-line arguments and its values
console.log("\nCommand line arguments: " + JSON.stringify(argsv.parseArgs("=")));

// Get value of a single command-line argument by its name
console.log("\nParam: { \"hello\" } Value: {\"" + argsv.getParam("hello") + "\"}");
console.log("\nParam: { \"oops\" } Value: {\"" + argsv.getParam("oops") + "\"}");

// Verify if a command-line argument exists
console.log("\nParam: { \"grand\" } Is Set: {\"" + argsv.isSet("grand") + "\"}");

Constructor

.ArgvParser #####.ArgvParser() ArgvParser - constructs a command-line arguments parser object,

Methods

.parseArgs( delimiter = 0 )

parses the command-line and returns an associative array of arguments and its values separated by a delimiter.

Warning: The using of all other ArgvParser object's methods is only possible after calling parseArgs method.

.getParam( param )

returns a value of an argument with a specific param name. If an argument with the given name does not exists, this method will return {Not_Found}, and {Not_Set}, in case when the value of an argument is missing.

.isSet( param )

performs a verification whether a value of an argument with the given name is set. This method can only be used when the command-line contains at least one argument which pair of its name and value are separated by the delimiter (e.g. mode='open'). This method returns true if the value of an argument is set and false unless otherwise.

Conclusion

That's All Folks :)

Author

Arthur V. Ratz @ Epsilon Software Development Labs.

Keywords

arguments node js parser

FAQs

Package last updated on 25 Mar 2018

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.