startup-args

0.0.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i startup-args

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

2.97 kB

Total Files

4

Last publish

Collaborators

  • 1euro7cent