Skip to content

Commit

Permalink
add checkConfiguration()
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Oct 28, 2019
1 parent 212814f commit f5adb00
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ function parse (args, opts) {
})
})

checkConfiguration()

var argv = { _: [] }
var notFlags = []

Expand Down Expand Up @@ -874,6 +876,20 @@ function parse (args, opts) {
return num === undefined
}

// check user configuration settings for inconsistencies
function checkConfiguration () {
// count keys should not be set as array/narg
Object.keys(flags.counts).find(key => {
if (checkAllAliases(key, flags.arrays)) {
error = Error(__('Invalid configuration: %s, opts.count excludes opts.array.', key))
return true
} else if (checkAllAliases(key, flags.nargs)) {
error = Error(__('Invalid configuration: %s, opts.count excludes opts.narg.', key))
return true
}
})
}

return {
argv: argv,
error: error,
Expand Down

0 comments on commit f5adb00

Please sign in to comment.