You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

get-them-args

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-them-args

Parse argument options

1.3.2
latest
Source
npm
Version published
Weekly downloads
308K
-13.91%
Maintainers
1
Weekly downloads
 
Created
Source

get-them-args

package version package downloads standard-readme compliant package license make a pull request Greenkeeper badge

Parse argument options

Table of Contents

About

Simple CLI argument parser hacked from minimist that adds support for objects and additional initialization options.

Install

$ npm install --save get-them-args
# Or
$ yarn add get-them-args

Usage

To use, provide arguments as argument:

const parse = require('get-them-args')
const options = {} // Options to be passed. CURRENTLY NONE AVAILABLE

// $ node ./example.js --dir . --command foo
console.log(parse(process.argv.slice(2) ))
// { unknown: [], dir: '.', command: 'foo' }

console.log(parse(process.argv))
// { unknown: [], dir: '.', command: 'foo' }

console.log(parse())
// { unknown: [], dir: '.', command: 'foo' }

For example, if the arguments provided are --hello world --parse=all --no-drugs --make-friends -n 4 -t 5, the function will return:

{ unknown: [],
  hello: 'world',
  parse: 'all',
  drugs: false,
  'make-friends': true,
  n: 4,
  t: 5
}

There is also support for parsing objects:


$ node example.js --headers={"Foo": "5", "bar": "6"}
# { unknown: [], headers: { Foo: 5, bar: 6 } }

All unparsed arguments will end up in the unknown array. The following types of arguments are supported:

--key=value
--key value
--key # true
--no-key # false
-key=value
-key value

Contribute

  • Fork it and create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request

License

MIT

Keywords

args

FAQs

Package last updated on 15 Jul 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