1.0.20 • Published 5 years ago

mr-arg-parser v1.0.20

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

Define Your Argumements:

let args = [
    { arg: '-d', name: 'debug', type: 'boolean', default: true }, 
    { arg: '-p', name: 'port', type: 'number', default: 8080 },
    { arg: '-h', name: 'host', type: 'string', default: '0.0.0.0' },
];

Call Arg Parser:

// $your-command /home /usr -d -p 4000  

const argParser = require('mr-arg-parser');

let parsed = argParser(args);

console.log(parsed)
/*
{ 
  _: [ '/home', '/usr' ],
  host: '0.0.0.0',
  port: '4000',
  debug: true 
}
*/

Arguement Definition Properties:

  • arg: how the argument should be specified on the command line.
  • name: how the arguement value shoud be displayed in the parsers output.
  • type: one of the following: 'array', 'boolean', 'string', 'number'
  • default: (optional) specifies default value for the arguement.

Array type arguements will contain all values from the arguements specifier until the parser comes across another argument specifier.

Values Before the first argument specifier are included in the parsers output as the "_" property.

1.0.20

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago