From 762bac2975055e76e995eaccc500045f8b2b4290 Mon Sep 17 00:00:00 2001 From: softprops Date: Thu, 13 Oct 2011 02:12:30 -0400 Subject: [PATCH] add support for a masked readline --- util/complete/LineReader.scala | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/util/complete/LineReader.scala b/util/complete/LineReader.scala index b8ab32f87..66479e736 100644 --- a/util/complete/LineReader.scala +++ b/util/complete/LineReader.scala @@ -10,9 +10,12 @@ package sbt abstract class JLine extends LineReader { protected[this] val reader: ConsoleReader - def readLine(prompt: String) = JLine.withJLine { unsynchronizedReadLine(prompt) } - private[this] def unsynchronizedReadLine(prompt: String) = - reader.readLine(prompt) match + def readLine(prompt: String, mask: Option[Char] = None) = JLine.withJLine { unsynchronizedReadLine(prompt, mask) } + private[this] def unsynchronizedReadLine(prompt: String, mask: Option[Char]) = + (mask match { + case Some(m) => reader.readLine(prompt, m) + case None => reader.readLine(prompt) + }) match { case null => None case x => Some(x.trim) @@ -59,7 +62,7 @@ private object JLine trait LineReader { - def readLine(prompt: String): Option[String] + def readLine(prompt: String, mask: Option[Char] = None): Option[String] } final class FullReader(historyPath: Option[File], complete: Parser[_]) extends JLine { @@ -81,4 +84,4 @@ class SimpleReader private[sbt] (historyPath: Option[File]) extends JLine object SimpleReader extends JLine { protected[this] val reader = JLine.createReader() -} \ No newline at end of file +}