Update completions to include ++ and exit/quit

This commit is contained in:
Mark Harrah 2009-12-07 08:38:35 -05:00
parent 9bfc8a8f4a
commit ef0bc1f2e4
2 changed files with 12 additions and 5 deletions

View File

@ -9,6 +9,7 @@ trait LineReader extends NotNull
}
class Completors(val projectAction: String, val projectNames: Iterable[String],
val generalCommands: Iterable[String], val propertyActions: Iterable[String],
val specificPrefix: String, val scalaVersions: Iterable[String],
val prefixes: Iterable[String]) extends NotNull
import jline.ConsoleReader
abstract class JLine extends LineReader
@ -102,7 +103,12 @@ class JLineReader(historyPath: Option[Path], completors: Completors, log: Logger
private def propertyCompletor(propertyNames: Iterable[String]) =
simpleArgumentCompletor(propertyActions, propertyNames)
private def prefixedCompletor(baseCompletor: Completor) =
singleArgumentCompletor(simpleCompletor(prefixes.toList.toArray[String]), baseCompletor)
singleArgumentCompletor(simpleCompletor(prefixes), baseCompletor)
private def specificCompletor(baseCompletor: Completor) =
{
val specific = simpleCompletor(specificPrefix :: Nil) // TODO
new ArgumentCompletor( Array( specific, simpleCompletor(scalaVersions), baseCompletor ) )
}
def setVariableCompletions(taskNames: Iterable[String], propertyNames: Iterable[String], extra: Iterable[(String, Iterable[String])] )
{
import scala.collection.immutable.TreeSet
@ -110,6 +116,6 @@ class JLineReader(historyPath: Option[Path], completors: Completors, log: Logger
val extraCompletors = for( (first, repeat) <- extra) yield repeatedArgumentCompletor(simpleCompletor(first :: Nil), simpleCompletor(repeat))
val baseCompletors = generalCompletor :: taskCompletor :: projectCompletor :: propertyCompletor(propertyNames) :: extraCompletors.toList
val baseCompletor = new MultiCompletor(baseCompletors.toArray)
completor.setCompletors( Array(baseCompletor, prefixedCompletor(baseCompletor)) )
completor.setCompletors( Array(baseCompletor, prefixedCompletor(baseCompletor), specificCompletor(baseCompletor)) )
}
}

View File

@ -258,7 +258,7 @@ class xMain extends xsbti.AppMain
object SpecificBuild
{
import java.util.regex.Pattern.{compile,quote}
val pattern = compile(quote(SpecificBuildPrefix) + """(\S+)\s*(.*)""")
val pattern = compile(quote(SpecificBuildPrefix) + """\s*(\S+)\s*(.*)""")
def unapply(s: String) =
{
val m = pattern.matcher(s)
@ -313,7 +313,8 @@ class xMain extends xsbti.AppMain
{
val projectNames = baseProject.projectClosure.map(_.name)
val prefixes = ContinuousExecutePrefix :: CrossBuildPrefix :: Nil
val completors = new Completors(ProjectAction, projectNames, interactiveCommands, List(GetAction, SetAction), prefixes)
val scalaVersions = baseProject.crossScalaVersions ++ Seq(baseProject.defScalaVersion.value)
val completors = new Completors(ProjectAction, projectNames, interactiveCommands, List(GetAction, SetAction), SpecificBuildPrefix, scalaVersions, prefixes)
val reader = new JLineReader(baseProject.historyPath, completors, baseProject.log)
val methodCompletions = for( (name, method) <- project.methods) yield (name, method.completions)
reader.setVariableCompletions(project.taskNames, project.propertyNames, methodCompletions)
@ -365,7 +366,7 @@ class xMain extends xsbti.AppMain
/** The list of all available commands at the interactive prompt in addition to the tasks defined
* by a project.*/
protected def interactiveCommands: Iterable[String] = basicCommands.toList ++ logLevels.toList
protected def interactiveCommands: Iterable[String] = basicCommands.toList ++ logLevels.toList ++ TerminateActions
/** The list of logging levels.*/
private def logLevels: Iterable[String] = TreeSet.empty[String] ++ Level.levels.map(_.toString)
/** The list of all interactive commands other than logging level.*/