lib/_cli/cli-util.js
function fillEmptyOptionsFromPrompt (options, args, callback, startPosition) {
  if (typeof startPosition === 'undefined') {
    startPosition = 0
  }
  if (startPosition < 0) {
    throw new RangeError('Start position must not be negative')
  }
  if (startPosition > args.length) {
    throw new RangeError('Start position (' + startPosition +
      ') is greater than length of args (' + args.length + ')')
  }
  if (startPosition === args.length) {
    callback(null, options)
  } else {
    var arg = args[startPosition]
    if (options[arg.name]) {
      fillEmptyOptionsFromPrompt(options, args, callback, startPosition + 1)
    } else {
      module.exports.getValueFromPrompt(arg.title || arg.name, arg.confirm,
        function (error, result) {
          if (error) {
            callback(error)
          } else {
            options[arg.name] = result
            fillEmptyOptionsFromPrompt(options, args, callback, startPosition + 1)
          }
        }
      )
    }
  }
}
function fillEmptyOptionsFromPrompt (options, args, callback, startPosition) {
  if (typeof startPosition === 'undefined') {
    startPosition = 0
  }
  if (startPosition < 0) {
    throw new RangeError('Start position must not be negative')
  }
  if (startPosition > args.length) {
    throw new RangeError('Start position (' + startPosition +
      ') is greater than length of args (' + args.length + ')')
  }
  if (startPosition === args.length) {
    callback(null, options)
  } else {
    var arg = args[startPosition]
    if (options[arg.name]) {
      fillEmptyOptionsFromPrompt(options, args, callback, startPosition + 1)
    } else {
      module.exports.getValueFromPrompt(arg.title || arg.name, arg.confirm,
        function (error, result) {
          if (error) {
            callback(error)
          } else {
            options[arg.name] = result
            fillEmptyOptionsFromPrompt(options, args, callback, startPosition + 1)
          }
        }
      )
    }
  }
}
function fillEmptyOptionsFromPrompt ( options , args , callback , startPosition ) { if ( typeof startPosition === 'undefined' ) { startPosition = 0 } if ( startPosition < 0 ) { throw new RangeError ( 'Start position must not be negative' ) } if ( startPosition > args . length ) { throw new RangeError ( 'Start position (' + startPosition + ') is greater than length of args (' + args . length + ')' ) } if ( startPosition === args . length ) { callback ( null , options ) } else { var arg = args [ startPosition ] if ( options [ arg . name ] ) { fillEmptyOptionsFromPrompt ( options , args , callback , startPosition + 1 ) } else { module . exports . getValueFromPrompt ( arg . title || arg . name , arg . confirm , function ( error , result ) { if ( error ) { callback ( error ) } else { options [ arg . name ] = result fillEmptyOptionsFromPrompt ( options , args , callback , startPosition + 1 ) } } ) } } }
For each arg in the args object, check to see if a corresponding non-empty
value is set in the options object. For any unset value, prompt the user
on the console for a value to set into the options object. Argument input
is processed asynchronously, with a call made to the function specified in
the callback argument after all arguments have been processed.
@param {Object} options - Object whose values should be non-empty for each
name in the corresponding args object.
@param {Array<Object>} args - Info for the key to check in the options
object.
@param {String} args.name - Name to match to a key in the options object.
@param {String} args.title - Title to display to the user when prompting
for a value to store in the options object.
@param {Boolean} [args.confirm=false] - Whether or not the user should be
prompted to enter the value twice for an option - to confirm the original
value.
@param {Function} callback - Function to invoke after all arguments have
been processed.
@param {Number} [startPosition=0] - Starting position (0-based) in the
arguments array to process.
For each arg in the args object check to see if a corresponding non - empty value is set in the options object . For any unset value prompt the user on the console for a value to set into the options object . Argument input is processed asynchronously with a call made to the function specified in the callback argument after all arguments have been processed .