2015-02-10 37 views
0

我的目标是有一个任务或设置,可以采取一些参数。inputKey基本示例不起作用

后仔细阅读the docs,我写了一首歌build.sbt,编译OK这个基本片断:

val servers = token(
    literal("desarrollo") | 
    literal("parametrizacion") 
) 

val deploy = inputKey[Unit]("Deploy to server") 
deploy := { 
    val serv = servers.parsed 
    println(s"Deploying to $serv") 
} 

我遇到从SBT命令行这个问题:

> deploy desarrollo 
[error] Expected ID character 
[error] Not a valid command: deploy 
[error] Expected project ID 
[error] Expected configuration 
[error] Expected ':' (if selecting a configuration) 
[error] Expected key 
[error] Expected '::' 
[error] Expected end of input. 
[error] Expected 'desarrollo' 
[error] Expected 'parametrizacion' 
[error] desploy desarrollo 
[error]  ^

标签为完成该论点不起作用。

我的目的是承认一个参数,其值可以是desarrollo或者parametrizacion

+0

我刚刚发现SBT预期的语法是'deploydesarrollo'和'deployparametrizacion'。 – 2015-02-10 09:57:59

回答

0

必须指定并丢弃空格。

val servers = token(' ' ~> (
    literal("desarrollo") | 
    literal("parametrizacion") 
)) 

val deploy = inputKey[Unit]("Deploy to server") 
deploy := { 
    val serv = servers.parsed 
    println(s"Deploying to $serv") 
} 

现在,deploy desarrollodeploy parametrizacion做的工作。

真的,需要指定初始空间,提供了更多的灵活性。 :-)