0.0.1 • Published 3 years ago

startup-args v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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