argumentate

A simple argv parser (like so many others)

Usage no npm install needed!

<script type="module">
  import argumentate from 'https://cdn.skypack.dev/argumentate';
</script>

README

Argumentate

A very simple argv parser

Installation

npm install argumentate

Usage

// make executable (not required, but needed if you are building a cli with a bin file (remember to put bin in your package.json!))
#!/usr/bin/env node

// import argumentate
let argumentate = require('argumentate');

// slice to remove path args
let { options, variables } = argumentate(process.argv.slice(2));

// be happy

Mappings

 argumentate(['start', '-p=8080', '-c', './myconfig.json'], {
    p: 'port',
    c: 'config'
 });
 
{ 
    options: {
        port: '8080',
        config: './myconfig.json'
    },
    variables: ['start']
}

More info in comments!!