Argumentate
A very simple argv parser
Installation
npm install argumentate
Usage
#!/usr/bin/env node
let argumentate = require('argumentate');
let { options, variables } = argumentate({
args: process.argv.slice(2),
mapping: {
c: 'config',
p: {
key: 'port',
help: 'Port to use when launching this command'
}
},
config: {
name: 'My CLI',
command: 'invoke-like-this'
}
);
Mappings
const { options, variables } = argumentate({
args: ['start', '-p=8080', '-c', './myconfig.json'],
mapping: {
c: 'config',
p: {
key: 'port',
help: 'Port to use when launching this command'
}
}
);
{
options: {
port: '8080',
config: './myconfig.json'
},
variables: ['start']
}