pxi-args
Version:
A command-line arguments parser for pxi (pixie), the small, fast, and magical command-line data processor
16 lines (14 loc) • 418 B
JavaScript
const combine = require('./combine')
const option = require('./option')
const pipe = require('./pipe')
module.exports = ({argv = [], toOpts, opts = [], toArgs, args = []}) => OPTS => {
const {errs: ERRS = [], args: ARGS} = combine(...OPTS.map(option))
return pipe(
({errs = [], argv = []}) => ({errs: errs.concat(ERRS), argv}),
...argv,
toOpts(ARGS),
...opts,
toArgs,
...args
)
}