aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/ParserTest.scala
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2018-04-29 17:59:47 -0700
committerJakob Odersky <jakob@odersky.com>2018-04-29 17:59:47 -0700
commiteef44a276ace54ef0b215c1c4b045afde40daf5b (patch)
tree83bc5aa811492ee8cb8ad6ec05258904d9a3d49d /src/test/scala/ParserTest.scala
parent4562b1b5754f4b840016be345eb6ee92f5abf258 (diff)
downloadcommando-eef44a276ace54ef0b215c1c4b045afde40daf5b.tar.gz
commando-eef44a276ace54ef0b215c1c4b045afde40daf5b.tar.bz2
commando-eef44a276ace54ef0b215c1c4b045afde40daf5b.zip
Specify action inline with command
Diffstat (limited to 'src/test/scala/ParserTest.scala')
-rw-r--r--src/test/scala/ParserTest.scala27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/scala/ParserTest.scala b/src/test/scala/ParserTest.scala
new file mode 100644
index 0000000..11694c4
--- /dev/null
+++ b/src/test/scala/ParserTest.scala
@@ -0,0 +1,27 @@
+package commando
+
+import utest._
+
+object ParserTest extends TestSuite {
+
+ implicit class EliteCommando(line: String) {
+ def parse(command: Command): Unit = {
+ val args = line.split(" ")
+ commando.parse(args, command)(err => throw new ParseException(err))
+ }
+ }
+
+ val tests = Tests {
+ "foo" - {
+ val command = cmd("cbx")(
+ opt("server", 'S', param = "url" -> false),
+ pos("number")
+ ).run(
+ ctx => println("yoyo, my context was: " + ctx)
+ )
+ "--server x 3 -S 5 --server=2 --server 2".parse(command)
+ println(command.usage)
+ }
+ }
+
+}