Lines Matching refs:key
58 var key = opt.key || opt
61 const assignment = Object.keys(opt).map(function (key) { argument
66 })[key]
71 flags[assignment][key] = true
74 flags.arrays[key] = true
75 flags.keys.push(key)
78 ;[].concat(opts.boolean).filter(Boolean).forEach(function (key) { argument
79 flags.bools[key] = true
80 flags.keys.push(key)
83 ;[].concat(opts.string).filter(Boolean).forEach(function (key) { argument
84 flags.strings[key] = true
85 flags.keys.push(key)
88 ;[].concat(opts.number).filter(Boolean).forEach(function (key) { argument
89 flags.numbers[key] = true
90 flags.keys.push(key)
93 ;[].concat(opts.count).filter(Boolean).forEach(function (key) { argument
94 flags.counts[key] = true
95 flags.keys.push(key)
98 ;[].concat(opts.normalize).filter(Boolean).forEach(function (key) { argument
99 flags.normalize[key] = true
100 flags.keys.push(key)
114 ;[].concat(opts.config).filter(Boolean).forEach(function (key) { argument
115 flags.configs[key] = true
125 extendAliases(opts.key, aliases, opts.default, flags.arrays)
128 Object.keys(defaults).forEach(function (key) { argument
129 (flags.aliases[key] || []).forEach(function (alias) {
130 defaults[alias] = defaults[key]
140 var key
169 key = arg.match(negatedBoolean)[1]
170 setArg(key, checkAllAliases(key, flags.arrays) ? [false] : false)
176 key = arg.match(/^--?(.+)/)[1]
180 if (checkAllAliases(key, flags.nargs) !== false) {
181 i = eatNargs(i, key, args)
183 } else if (checkAllAliases(key, flags.arrays)) {
184 i = eatArray(i, key, args)
190 !checkAllAliases(key, flags.bools) &&
191 !checkAllAliases(key, flags.counts)) {
192 setArg(key, next)
195 setArg(key, next)
198 setArg(key, defaultValue(key))
210 key = arg.match(/^-(.\..+)/)[1]
213 !checkAllAliases(key, flags.bools) &&
214 !checkAllAliases(key, flags.counts)) {
215 setArg(key, next)
218 setArg(key, defaultValue(key))
229 key = letters[j]
232 if (checkAllAliases(key, flags.nargs)) {
234 i = eatNargs(i, key, args)
236 } else if (checkAllAliases(key, flags.arrays)) {
238 i = eatArray(i, key, args)
240 setArg(key, value)
269 key = arg.slice(-1)[0]
271 if (!broken && key !== '-') {
274 if (checkAllAliases(key, flags.nargs) !== false) {
275 i = eatNargs(i, key, args)
277 } else if (checkAllAliases(key, flags.arrays)) {
278 i = eatArray(i, key, args)
284 !checkAllAliases(key, flags.bools) &&
285 !checkAllAliases(key, flags.counts)) {
286 setArg(key, next)
289 setArg(key, next)
292 setArg(key, defaultValue(key))
322 Object.keys(flags.counts).forEach(function (key) { argument
323 if (!hasKey(argv, key.split('.'))) setArg(key, 0)
328 notFlags.forEach(function (key) { argument
329 argv[notFlagsArgv].push(key)
333 Object.keys(argv).filter(key => key !== '--' && key.includes('-')).forEach(key => {
334 delete argv[key]
351 function eatNargs (i, key, args) { argument
353 const toEat = checkAllAliases(key, flags.nargs)
356 setArg(key, defaultValue(key))
368 if (available < toEat) error = Error(__('Not enough arguments following: %s', key))
372 setArg(key, args[ii])
381 function eatArray (i, key, args) { argument
385 if (checkAllAliases(key, flags.bools) && !(/^(true|false)$/.test(next))) {
390 if (defaults.hasOwnProperty(key)) {
391 argsToSet.push(defaults[key])
398 argsToSet.push(processValue(key, next))
402 setArg(key, argsToSet)
406 function setArg (key, val) { argument
407 if (/-/.test(key) && configuration['camel-case-expansion']) {
408 var alias = key.split('.').map(function (prop) {
411 addNewAlias(key, alias)
414 var value = processValue(key, val)
416 var splitKey = key.split('.')
420 if (flags.aliases[key] && flags.aliases[key].forEach) {
421 flags.aliases[key].forEach(function (x) {
442 if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) {
443 var keys = [key].concat(flags.aliases[key] || [])
444 keys.forEach(function (key) { argument
445 argv.__defineSetter__(key, function (v) {
449 argv.__defineGetter__(key, function () {
456 function addNewAlias (key, alias) { argument
457 if (!(flags.aliases[key] && flags.aliases[key].length)) {
458 flags.aliases[key] = [alias]
462 addNewAlias(alias, key)
466 function processValue (key, val) { argument
476 if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
481 ? val.map(function (v) { return maybeCoerceNumber(key, v) })
482 : maybeCoerceNumber(key, val)
485 if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === 'boolean')) {
490 if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) {
497 function maybeCoerceNumber (key, value) { argument
498 …if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !Array.isArray(v…
502 …if (shouldCoerceNumber || (!isUndefined(value) && checkAllAliases(key, flags.numbers))) value = Nu…
548 Object.keys(config).forEach(function (key) { argument
549 var value = config[key]
550 var fullKey = prev ? prev + '.' + key : key
583 var keys = envVar.split('__').map(function (key, i) { argument
585 key = key.substring(prefix.length)
587 return camelCase(key)
600 Object.keys(argv).forEach(function (key) { argument
601 …if (!applied.hasOwnProperty(key)) { // If we haven't already coerced this option via one of its al…
602 coerce = checkAllAliases(key, flags.coercions)
605 var value = maybeCoerceNumber(key, coerce(argv[key]))
606 ;([].concat(flags.aliases[key] || [], key)).forEach(ali => {
618 flags.keys.forEach((key) => {
620 if (~key.indexOf('.')) return
621 if (typeof argv[key] === 'undefined') argv[key] = undefined
627 Object.keys(defaults).forEach(function (key) { argument
628 if (!hasKey(obj, key.split('.'))) {
629 setKey(obj, key.split('.'), defaults[key])
631 ;(aliases[key] || []).forEach(function (x) {
633 setKey(obj, x.split('.'), defaults[key])
644 keys.slice(0, -1).forEach(function (key) { argument
645 o = (o[key] || {})
648 var key = keys[keys.length - 1]
651 else return key in o
659 keys.slice(0, -1).forEach(function (key, index) { argument
662 key = sanitizeKey(key)
664 if (typeof o === 'object' && o[key] === undefined) {
665 o[key] = {}
668 if (typeof o[key] !== 'object' || Array.isArray(o[key])) {
670 if (Array.isArray(o[key])) {
671 o[key].push({})
673 o[key] = [o[key], {}]
677 o = o[key][o[key].length - 1]
679 o = o[key]
685 const key = sanitizeKey(keys[keys.length - 1])
692 if (!duplicate && checkAllAliases(key, flags.nargs)) {
694 …if ((!isUndefined(o[key]) && flags.nargs[key] === 1) || (Array.isArray(o[key]) && o[key].length ==…
695 o[key] = undefined
700 o[key] = increment(o[key])
701 } else if (Array.isArray(o[key])) {
703 …o[key] = configuration['flatten-duplicate-arrays'] ? o[key].concat(value) : (Array.isArray(o[key][…
705 o[key] = value
707 o[key] = o[key].concat([value])
709 } else if (o[key] === undefined && isTypeArray) {
710 o[key] = isValueArray ? value : [value]
711 } else if (duplicate && !(o[key] === undefined || checkAllAliases(key, flags.counts))) {
712 o[key] = [ o[key], value ]
714 o[key] = value
721 Object.keys(obj || {}).forEach(function (key) { argument
725 if (flags.aliases[key]) return
727 flags.aliases[key] = [].concat(aliases[key] || [])
729 flags.aliases[key].concat(key).forEach(function (x) {
732 if (c !== key && flags.aliases[key].indexOf(c) === -1) {
733 flags.aliases[key].push(c)
739 flags.aliases[key].concat(key).forEach(function (x) {
742 if (c !== key && flags.aliases[key].indexOf(c) === -1) {
743 flags.aliases[key].push(c)
748 flags.aliases[key].forEach(function (x) {
749 flags.aliases[x] = [key].concat(flags.aliases[key].filter(function (y) {
758 function checkAllAliases (key, flag) { argument
760 var toCheck = [].concat(flags.aliases[key] || [], key)
762 toCheck.forEach(function (key) { argument
763 if (flag.hasOwnProperty(key)) isSet = flag[key]
769 function hasAnyFlag (key) { argument
774 return flag[key]
836 function defaultValue (key) { argument
837 if (!checkAllAliases(key, flags.bools) &&
838 !checkAllAliases(key, flags.counts) &&
839 `${key}` in defaults) {
840 return defaults[key]
842 return defaultForType(guessType(key))
860 function guessType (key) { argument
863 if (checkAllAliases(key, flags.strings)) type = 'string'
864 else if (checkAllAliases(key, flags.numbers)) type = 'number'
865 else if (checkAllAliases(key, flags.bools)) type = 'boolean'
866 else if (checkAllAliases(key, flags.arrays)) type = 'array'
904 Object.keys(aliases).forEach(function (key) { argument
906 [].concat(aliases[key], key)
963 function sanitizeKey (key) { argument
964 if (key === '__proto__') return '___proto___'
965 return key