startup-args
v0.0.1
Published
This allows you to manage startup arguments with ease
Downloads
8
Readme
Installation
npm i startup-args
Usage
const startup = require("startup-args");
// new startup.StartupArgs(seperator default -);
const args = new startup.StartupArgs("-");
// if you start the script with `node file.js -debug -limit 100 -block ip1 ip2 ip3`
// you should get something like this:
console.log(args);
/*
StartupArgs {
totalArgs: [
'-debug', '-limit',
'100', '-block',
'ip1', 'ip2',
'ip3'
],
args: {
debug: { subArgs: [], boolValue: true },
limit: { subArgs: [ '100' ], boolValue: false },
block: { subArgs: [ 'ip1', 'ip2', 'ip3' ], boolValue: false }
}
}
*/
// you can get single arg values by using `args.get(key)`
console.log(args.get("debug")); // true
console.log(args.get("limit")); // ['100']
console.log(args.get("block")); // [ 'ip1', 'ip2', 'ip3' ]
console.log(args.get("asdasdasd")); // undefined