opted
Stringify an object to command line options
Installation
npm install --save opted
Usage
Opted is not a command line option parser. Rather, it is a library for stringifying an object into a list of command line arguments. E.g.
var opted = ;var args = ;console; // ['--foo', 'bar']
Types of flags
Long
Options are kebab-cased and prefixed with '--'.
console; // ['--foo', 'bar']console; // ['--foo-bar', 'baz']
Short
Options that have single letter abbreviations can also be used.
console; // ['-f', 'bar']
Boolean
Options that are simple "on", but have no value, can be set to true
. Setting a flag to false, will add 'no' to the beginning.
console; // ['--bananas']console; // ['--no-bananas']
Equal style
Options that include an equal sign will keep the equal sign.
console; // ['--name=Andrew']
List
Multiple options for a single flag can be passed in an array.
console; // ['--member', 'Bob', '--member', 'Larry']
But wait, the tool I need to pass args to is some bizarre abomination like "find" that uses single dashes...
No problem. Just enable crazy-arg mode by passing true as the second parameter.
console; // ['-hello', 'world']
Contributing
Please see the contribution guidelines.