2014-08-31 56 views

回答

3

繼文件Input Tasks(帶到輸入任務的名稱主要的變化所以它的greeting):

import sbt.complete.Parsers.spaceDelimited 

val greeting = inputKey[Unit]("A demo input task.") 

greeting := { 
    val args: Seq[String] = spaceDelimited("<arg>").parsed 
    args foreach println 
} 

隨着build.sbt上面,你可以從控制檯調用輸入任務:

> greeting "hello world" 
hello world 

,或者在命令行:

➜ so-25596401 xsbt 'greeting "hello world"' 
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins 
[info] Set current project to so-25596401 (in build file:/Users/jacek/sandbox/so-25596401/) 
hello world 
[success] Total time: 0 s, completed Sep 1, 2014 1:34:31 AM 

注意,指定什麼是帶參數的單任務/命令引號。