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

argv-config

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argv-config

transfer argv to a config object

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

argv-config

transfer argv to a config object

Install

npm install argv-config

Usage


var argv_config= require("argv-config");
//argv_config= function ([target [, argv [, workPath]]])

var cfg = argv_config();		//default usage

cfg = argv_config({}, "--a 001 --b --c cc ".split(" "));		// `--key` `value` pair set string value
assert(JSON.stringify(cfg) === '{"a":"001","b":null,"c":"cc"}');		// single `--key` set null

cfg = argv_config({}, "--a 001 --b bb --config {b:22}".split(" "));	//--config {json-data}
assert(JSON.stringify(cfg) === '{"a":"001","b":22}');		//value will be replaced by the later

cfg = argv_config({}, "--a 001 --b bb --config {b:22} -c {b:33} -d 44".split(" "), null,
	{ "-c": "config", "-d": "dd" });	//replace short key with normal key (prefixed with '--')
assert(JSON.stringify(cfg) === '{"a":"001","b":33,"dd":"44"}');

cfg = argv_config({}, "--a 001 --b bb --config ./test-config.json".split(" "), __dirname);	//--config from json file
assert(JSON.stringify(cfg) === '{"a":"001","b":22}');

cfg = argv_config({}, "--a 001 --b bb --config ./test-config.js".split(" "), __dirname);	//--config from js module
assert(JSON.stringify(cfg) === '{"a":"001","b":22}');

Keywords

argv

FAQs

Package last updated on 05 Jan 2022

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