extract-flags
Extract command-line arguments from a list, removing matches from the original array. Useful for providing custom arguments for a wrapper executable, but passing unexpected arguments back onto the original executable if not expected.
Only supports a subset of what you'd get with minimist, so unless you're explicitly looking to modify the arguments array you're better off using that module.
Usage
extract(argv, flags)
Where argv
is an array of arguments, and flags
is an object formatted
like so:
t: Stringtransform: Stringdebug: Boolean
Each key represents a command-line flag, and the value should be either
String
, Number
or Boolean
to denote its type. argv
will be modified
in-place to remove matched flags, and you will get an object in return
with the extracted values:
t: 'envify' 'es6ify'transform: 'installify'debug: true
Example
Here's a simple example of the kind of thing you might want to use
extract-flags
for:
var spawn = spawnvar extract =var argv = processargvvar options =if optionsdebugprocessenvNODE_ENV = 'development'var ps =var input = processstdinoptionstransforminput
License
MIT. See LICENSE.md for details.