Socket
Book a DemoInstallSign in
Socket

get-them-args

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-them-args

Parse argument options

Source
npmnpm
Version
1.2.2
Version published
Weekly downloads
867K
-10%
Maintainers
1
Weekly downloads
 
Created
Source

😑 get-them-args


Parse argument options
Standard Travis Standard Readme PRs Donate


Built with ❤︎ by Tiaan du Plessis

Table of Contents

Table of Contents
  • Install
  • Usage
  • API
  • Contribute
  • License
  • Install

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

    Usage

    To use, provide arguments as argument :smirk:.

    const getThemArgs = require('get-them-arg')
    const args = process.argv.slice(2) // Array of arguments to process
    const options = {} // Options to be passed. CURRENTLY NONE AVAILABLE
    
    // $ node ./example.js --dir . --command foo
    console.log(getThemArgs(args))
    // Will print out: { 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
    

    API

    This module exports a single function with the signature:

    getThemArgs(arguments, options)
    

    arguments

    Array of arguments to parse.

    Options

    Currently no options available. Added for future additions.

    Contribute

    Contributions are welcome. Please open up an issue or create PR if you would like to help out.

    Small note: If editing the README, please conform to the standard-readme specification.

    License

    Licensed under the MIT License.

    Keywords

    args

    FAQs

    Package last updated on 23 Apr 2017

    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