aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/dargs.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/dargs.js')
-rw-r--r--src/dargs.js17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/dargs.js b/src/dargs.js
index e5c574c..de049ba 100644
--- a/src/dargs.js
+++ b/src/dargs.js
@@ -1,16 +1,7 @@
1'use strict'; 1'use strict';
2 2
3function dargs(obj) { 3const dargs = require('dargs');
4 return Object.keys(obj).reduce((args, key) => {
5 const arg = '--' + key.replace(/[A-Z]/g, '-$&').toLowerCase();
6 const val = obj[key]
7 4
8 if (key === '_') val.forEach(v => args.push(v)) 5module.exports = function(obj){
9 else if (Array.isArray(val)) val.forEach(v => args.push(arg, v)) 6 return dargs(obj, {ignoreFalse: true});
10 else args.push(arg, obj[key]) 7};
11
12 return args.filter(arg => (typeof arg !== 'boolean'))
13 }, [])
14}
15
16module.exports = dargs;