/*
 * sbt
 * Copyright 2011 - 2018, Lightbend, Inc.
 * Copyright 2008 - 2010, Mark Harrah
 * Licensed under Apache License 2.0 (see LICENSE)
 */

package sbt

import sbt.internal.util.{ SimpleReader, Terminal }

trait CommandLineUIService extends InteractionService {
  override def readLine(prompt: String, mask: Boolean): Option[String] = {
    val maskChar = if (mask) Some('*') else None
    SimpleReader.readLine(prompt, maskChar)
  }
  // TODO - Implement this better.
  override def confirm(msg: String): Boolean = {
    object Assent {
      def unapply(in: String): Boolean = {
        (in == "y" || in == "yes")
      }
    }
    SimpleReader.readLine(msg + " (yes/no): ", None) match {
      case Some(Assent()) => true
      case _              => false
    }
  }

  override def terminalWidth: Int = Terminal.get.getWidth

  override def terminalHeight: Int = Terminal.get.getHeight
}

object CommandLineUIService extends CommandLineUIService

/*
 * sbt
 * Copyright 2011 - 2018, Lightbend, Inc.
 * Copyright 2008 - 2010, Mark Harrah
 * Licensed under Apache License 2.0 (see LICENSE)
 */

package sbt

import sbt.internal.util.{ SimpleReader, Terminal }

trait CommandLineUIService extends InteractionService {
  override def readLine(prompt: String, mask: Boolean): Option[String] = {
    val maskChar = if (mask) Some('*') else None
    SimpleReader(Terminal.get).readLine(prompt, maskChar)
  }
  // TODO - Implement this better.
  override def confirm(msg: String): Boolean = {
    object Assent {
      def unapply(in: String): Boolean = {
        (in == "y" || in == "yes")
      }
    }
    SimpleReader(Terminal.get).readLine(msg + " (yes/no): ", None) match {
      case Some(Assent()) => true
      case _              => false
    }
  }

  override def terminalWidth: Int = Terminal.get.getWidth

  override def terminalHeight: Int = Terminal.get.getHeight
}

object CommandLineUIService extends CommandLineUIService

Fix interaction service for thin client
Fix interaction service for thin client

The global SimpleReader hardwires Terminal.console so it won't work with
the ThinClient.
