title: Scala command line parser using Scallop
body: <p>I'm fairly new to Scala and need to build a really simple command line parser which provides something like the following which I created using JRuby in a few minutes:-</p>
  
  <pre><code>java -jar demo.jar --help
  
  Command Line Example Application
  
  Example: java -jar demo.jar --dn "CN=Test" --nde-url "http://www.example.com" --password "password"
  
  For usage see below:
  
      -n http://www.example.com
      -p, --password             set the password
      -c, --capi                 set add to Windows key-store
      -h, --help                 Show this message
      -v, --version              Print version
  </code></pre>
  
  <p><a href="https://github.com/Rogach/scallop" rel="noreferrer">Scallop</a> looks like it will do the trick, but I can't seem to find a simple example that works! All of the examples I've found seem to be fragmented and don't work for some reason or other.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I found this example which works, but I'm not sure how to bind it into the actual args within the main method. </p>
  
  <pre><code>import org.rogach.scallop._; 
  
  object cmdlinetest {
    def main(args: Array[String]) 
  
      val opts = Scallop(List("-d","--num-limbs","1"))
        .version("test 1.2.3 (c) 2012 Mr Placeholder")
        .banner("""Usage: test [OPTION]... [pet-name]
                  |test is an awesome program, which does something funny
                  |Options:
                  |""".stripMargin)
        .footer("\nFor all other tricks, consult the documentation!")
        .opt[Boolean]("donkey", descr = "use donkey mode")
        .opt("monkeys", default = Some(2), short = 'm')
        .opt[Int]("num-limbs", 'k',
        "number of libms", required = true)
        .opt[List[Double]]("params")
        .opt[String]("debug", hidden = true)
        .props[String]('D',"some key-value pairs")
        // you can add parameters a bit later
        .args(List("-Dalpha=1","-D","betta=2","gamma=3", "Pigeon"))
        .trailArg[String]("pet name")
        .verify
  
      println(opts.help)
    }
  }
  </code></pre>