New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@kamidere/node-args

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

@kamidere/node-args

Most minimalistic parameter processor for node.

latest
Source
npmnpm
Version
3.0.1
Version published
Maintainers
1
Created
Source

Fork of christiansandor/args
Build Status Coverage Status

Args

The most minimalistic parameter processor for node. Really.

Usage

Couldn't be simpler, just install it like:

npm install @kamidere/node-args

And use it as:

const { getArgs } = require('@kamidere/node-args');

const args = getArgs(process.argv);

const anyString = "-a --test nope";
const argsFromString = getArgs(anyString.split(' '));

Call node with

  • your named parameters prefixed with --
  • your shorthand parameters prefixed with - (with multiple parameters in mind like -ab = -a -b)
  • your parameters and assigned values separated with a space or an equals sign

my.js

const { getArgs } = require('@kamidere/node-args');

console.log(getArgs(process.argv));
node my.js -t -ab=2 -c false -p no some additional data 2 --argsis awesome --another=1

So you will get:

{
    additional: ['node', 'node file path', 'some', 'additional', 'data', 2],
    t: true,
    a: 2,
    b: 2,
    c: false,
    p: 'no',
    argsis: 'awesome',
    another: 1
};

Yay.

Side note: It's build upon TypeScript and tested thoroughly.

Build

The source files are in the src folder, and the available scripts are

  • npm run build:src to build without tests
  • npm run build:tests to build with tests
  • npm test to run tests

Please do contribute if you find a better, faster or easier way to process arguments.

Keywords

node-args

FAQs

Package last updated on 27 Feb 2021

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