node-arg
v1.0.1
Published
A python-like argparser for node.js
Downloads
3
Maintainers
Readme
node-arg
A python-like argparser for node.js
Example
const ArgumentParser = require('node-arg');
const parser = new ArgumentParser();
parser.add_argument('--port', { type: 'number', default: 8080 });
parser.add_argument('--env', { type: 'string', default: 'dev' });
parser.add_argument('--restart', { type: 'boolean', default: true });
parser.add_argument('--watch', { type: 'boolean', default: true });
parser.add_argument('--static-dir', { type: 'string', default: 'static' });
const args = parser.parse_args();
Usage
Command line
node server.js --port 3000 --watch false
Expected result
{
port: 3000,
env: 'dev',
restart: true,
watch: false,
static_dir: 'static'
}