blob: 043a9f25a214322e43f26873b87c33fc6d95bcdc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package example
object Main extends App {
val cmd = new commando.Command("xorc", "") {
val version = named("version", 'V')
.action(() => println("version 1"))
named("verbose", 'v')
.info("Set verbosity level. This option may be repeated.")
.optionalArg("level")
.action(level => println(s"level $level"))
positional("FILES")
.action { s =>
val f = new java.io.File(s)
if (!f.exists()) error(s"File $s does not exit")
println(f)
}
.repeat()
val comp = named("completion")
.info(
s"Print bash completion. Add ${name} --completions to your bashrc to get completions."
)
.action(() => println(completion()))
named("help", 'h')
.info("print a help message")
.action(() => println(usage()))
}
cmd.parse(args) match {
case None =>
case Some(error) =>
println(error)
sys.exit(1)
}
}
|