Skip to content

Instantly share code, notes, and snippets.

@trane
Last active September 18, 2015 19:58
Show Gist options
  • Select an option

  • Save trane/3ee429d22175727eae92 to your computer and use it in GitHub Desktop.

Select an option

Save trane/3ee429d22175727eae92 to your computer and use it in GitHub Desktop.
import com.twitter.app._
import java.net.InetSocketAddress
object Main extends App {
// set default values for this flag, if it isn't passed in at command line
val memcachedF = flag("memcached", Seq(new InetSocketAddress(0)), "memcached addresses")
// print out the current value of the memcached flag (at this point, it's just the default value)
println(s"1. memcacheds from defaults: ${memcachedF()}")
/**
* the method that runs when we call "run"
* it will pass the cli args through the initialized parser and update the flag values
*/
def main : Unit =
println(s"2. memcacheds from args ${memcachedF()}")
}
> run -memcached=localhost:11211,10.2.2.1:11211
1. memcacheds from defaults: List(0.0.0.0/0.0.0.0:0)
2. memcacheds from args ArraySeq(localhost/127.0.0.1:11211, /10.2.2.1:11211)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment