0.4.4 • Published 3 years ago

micro-ap v0.4.4

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

npm version types size coverage Dependencies devDependencies License

tiny arg parser


Installation

$ npm i micro-ap

About

micro-a is a small and opinionated argument parser library without any additional dependencies.

Functions

flag(flag, name, fallback = false)

Extract flag arguments

  • flag (string); one char as flag e.g. -f
  • name (string); full name of a flag e.g. --file
  • fallback (string); default value

command(name, fallback = false)

Extract command arguments

  • name (string); name of the command e.g. install
  • fallback (string); default value

get()

Returns the parsed arguments as an object

Examples

const parser = require('micro-ap');

// simple
// node index.js install test --verbose
parser(process.argv)
    .flag('v', 'verbose')
    .command('install')
    .get() // returns {"verbose": true, "install": "test"}
;

// complex
// node index.js install foo -o console -f one.js two.js three.js -f four.js
parser(process.argv)
    .command('install')
    .flag('f', 'file')
    .flag('o', 'output')
    .flag('v', 'verbose', true)
    .get() // returns {"install": "test", "verbose": true, "output": "console", "file": ["one.js", "two.js", "three.js", "four.js"]}
;

Licence

MIT License, see LICENSE

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago