The easy way to make command line arguments.
const cargv = require('cargv');
const options = cargv.read()
.add({
name: 'cool',
type: 'bool', // or boolean (any number above 0 is true, along with 'on' and 'true')
aliases: ['cargv_is_cool'],
default: [false],
description: 'Is CArgV cool?'
}).done();
console.log(options);
// Result:
{
cool: {
name: 'cool',
value: [ false ],
arguments: 0
}
}
You may have noticed that value
is an array. That's because you can have multiple arguments.
To add multiple arguments, simply add an arguments
property to the option. The arguments
property takes an integer which starts from 0. If you'd like different arguments to have different types, just make
the type property an array.
Example:
const options = cargv.read()
.add({
name: 'cool',
type: ['bool', 'num'], // or boolean (any number above 0 is true, along with 'on' and 'true')
aliases: ['cargv_is_cool'],
default: [false, 5],
description: 'Is CArgV cool?',
arguments: 2
}).done();
Can be 'true', 'on', any number above 0 for true. anything else is considered false.
Takes no arguments. If the tag is present, the value will be true.
Recommended use with default
set to [false]
Takes a comma seperated (which can be changed by defining a seperator
property on the option) list.
Takes anything as a string.
Takes anything as a float.
A mix of 'string'
and 'number'