Hi π
This is a very small 1.33 KB package that does just one simple task to get the user's input data passed from your terminal, split it and send it back to and object, That's it, no big config or API just a tiny function.
Install
npm i argv-user-input
Usage π‘
#!/usr/bin/env node
import parseArgvData from 'argv-user-input';
const argvs = parseArgvData();
foo.js
With no commands or options.
$ foo.js
console.log(argvs);
/*
{
commands: [],
options: {},
}
*/
With commands and no option.
$ foo.js start test
console.log(argvs);
/*
{
commands: ['start', 'test'],
options: {},
}
*/
With commands and options.
$ foo.js start test --skip -p ./dev
console.log(argvs);
/*
{
commands: ['start', 'test'],
options: {
skip: true,
p: './dev'
},
}
*/
With option and no command.
$ foo.js --name=foo
console.log(argvs);
/*
{
commands: [],
options: {
name: 'foo'
},
}
*/
Good code and have fun β¨
Top comments (0)