lib/index.js
function(message, options, callback) {
    // If no callback given create one
    if( ! callback) callback = function() {}

    // If a previous terminal has been opened then close it
    if(terminal) terminal.close()

    terminal = t_menu(this.options.menu)

    // Reset the terminal, clearing all contents
    if(this.options.reset) terminal.reset()

    if(this.options.title) terminal.write(this.options.formatTitle() + '\n\n')

    // Write message or messages to the console
    if(_.isString(message)) message = [message]
    _.each(message, function(message) {
      terminal.write(chalk.bold(message + '\n'))
    })

    terminal.write('\n')

    // If options were given write them to the console
    if(options) {
      _.each(options, function(option) {
        terminal.add(option)
      })

      terminal.write('\n')
      terminal.add('Cancel')
    }

    // Pipe the terminal menu to the console
    process.stdin.pipe(terminal.createStream()).pipe(process.stdout)

    // Run callback when a terminal item is selected
    terminal.on('select', function(item, index) {
      if(item == 'Cancel') return callback(Error('Cancelled by user'))
      callback(null, item, index)
    })

    terminal.on('error', function(err) {
      callback(err)
    })

    process.stdin.on('error', function(err) {
      callback(err)
    })

    return terminal
  }
function(message, options, callback) {
    // If no callback given create one
    if( ! callback) callback = function() {}

    // If a previous terminal has been opened then close it
    if(terminal) terminal.close()

    terminal = t_menu(this.options.menu)

    // Reset the terminal, clearing all contents
    if(this.options.reset) terminal.reset()

    if(this.options.title) terminal.write(this.options.formatTitle() + '\n\n')

    // Write message or messages to the console
    if(_.isString(message)) message = [message]
    _.each(message, function(message) {
      terminal.write(chalk.bold(message + '\n'))
    })

    terminal.write('\n')

    // If options were given write them to the console
    if(options) {
      _.each(options, function(option) {
        terminal.add(option)
      })

      terminal.write('\n')
      terminal.add('Cancel')
    }

    // Pipe the terminal menu to the console
    process.stdin.pipe(terminal.createStream()).pipe(process.stdout)

    // Run callback when a terminal item is selected
    terminal.on('select', function(item, index) {
      if(item == 'Cancel') return callback(Error('Cancelled by user'))
      callback(null, item, index)
    })

    terminal.on('error', function(err) {
      callback(err)
    })

    process.stdin.on('error', function(err) {
      callback(err)
    })

    return terminal
  }
function ( message , options , callback ) { // If no callback given create one if ( ! callback ) callback = function ( ) { } // If a previous terminal has been opened then close it if ( terminal ) terminal . close ( ) terminal = t_menu ( this . options . menu ) // Reset the terminal, clearing all contents if ( this . options . reset ) terminal . reset ( ) if ( this . options . title ) terminal . write ( this . options . formatTitle ( ) + '\n\n' ) // Write message or messages to the console if ( _ . isString ( message ) ) message = [ message ] _ . each ( message , function ( message ) { terminal . write ( chalk . bold ( message + '\n' ) ) } ) terminal . write ( '\n' ) // If options were given write them to the console if ( options ) { _ . each ( options , function ( option ) { terminal . add ( option ) } ) terminal . write ( '\n' ) terminal . add ( 'Cancel' ) } // Pipe the terminal menu to the console process . stdin . pipe ( terminal . createStream ( ) ) . pipe ( process . stdout ) // Run callback when a terminal item is selected terminal . on ( 'select' , function ( item , index ) { if ( item == 'Cancel' ) return callback ( Error ( 'Cancelled by user' ) ) callback ( null , item , index ) } ) terminal . on ( 'error' , function ( err ) { callback ( err ) } ) process . stdin . on ( 'error' , function ( err ) { callback ( err ) } ) return terminal }
Write a message or menu to the terminal

@method write
@param {String|Array} message Message or messages
@param {Array} options Selectable menu options
@param {Function} callback
@return {Object} Terminal object
Write a message or menu to the terminal