mirror of https://github.com/sbt/sbt.git
apply <module>* : command to apply State transformations defined by module names
This commit is contained in:
parent
5d398bc4a1
commit
619b97d215
|
|
@ -178,11 +178,8 @@ object Help
|
|||
def briefOnly(help: Seq[(String, String)]): Help = apply(help, Map.empty[String,String])
|
||||
def detailOnly(help: Seq[(String, String)]): Help = apply(Nil, help.toMap)
|
||||
}
|
||||
trait CommandDefinitions
|
||||
trait CommandDefinitions extends (State => State)
|
||||
{
|
||||
def commands: Seq[Command]
|
||||
def commands: Seq[Command] = ReflectUtilities.allVals[Command](this).values.toSeq
|
||||
def apply(s: State): State = s ++ commands
|
||||
}
|
||||
trait ReflectedCommands extends CommandDefinitions
|
||||
{
|
||||
def commands = ReflectUtilities.allVals[Command](this).values.toSeq
|
||||
}
|
||||
|
|
@ -197,6 +197,10 @@ ReadCommand + ReadFiles + """
|
|||
|
||||
You probably need to escape this command if entering it at your shell."""
|
||||
|
||||
def ApplyCommand = "apply"
|
||||
def ApplyBrief = (ApplyCommand + " <module-name>*", ApplyDetailed)
|
||||
def ApplyDetailed = "Transforms the current State by calling <module-name>.apply(currentState) for each listed."
|
||||
|
||||
def DefaultsCommand = "add-default-commands"
|
||||
def DefaultsBrief = (DefaultsCommand, DefaultsDetailed)
|
||||
def DefaultsDetailed = "Registers default built-in commands"
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ object BuiltinCommands
|
|||
def ConsoleCommands: Seq[Command] = Seq(ignore, exit, IvyConsole.command, act, nop)
|
||||
def ScriptCommands: Seq[Command] = Seq(ignore, exit, Script.command, act, nop)
|
||||
def DefaultCommands: Seq[Command] = Seq(ignore, help, about, reboot, read, history, continuous, exit, loadProject, loadProjectImpl, loadFailed, Cross.crossBuild, Cross.switchVersion,
|
||||
projects, project, setOnFailure, clearOnFailure, ifLast, multi, shell, set, tasks, inspect, eval, alias, append, last, lastGrep, boot, nop, sessionCommand, act)
|
||||
projects, project, setOnFailure, clearOnFailure, ifLast, multi, shell, set, tasks, inspect, eval, alias, append, last, lastGrep, boot, nop, sessionCommand, call, act)
|
||||
def DefaultBootCommands: Seq[String] = LoadProject :: (IfLast + " " + Shell) :: Nil
|
||||
|
||||
def boot = Command.make(BootCommand)(bootParser)
|
||||
|
|
@ -302,6 +302,11 @@ object BuiltinCommands
|
|||
def defaults = Command.command(DefaultsCommand) { s =>
|
||||
s ++ DefaultCommands
|
||||
}
|
||||
def call = Command(ApplyCommand, ApplyBrief, ApplyDetailed)(_ => spaceDelimited("<class name>")) { (state,args) =>
|
||||
val loader = getClass.getClassLoader
|
||||
val loaded = args.map(arg => ModuleUtilities.getObject(arg, loader))
|
||||
(state /: loaded) { case (s, obj: (State => State)) => obj(s) }
|
||||
}
|
||||
|
||||
def initialize = Command.command(InitCommand) { s =>
|
||||
/*"load-commands -base ~/.sbt/commands" :: */readLines( readable( sbtRCs(s) ) ) ::: s
|
||||
|
|
|
|||
Loading…
Reference in New Issue