Skip to content

Commit 5005e9f

Browse files
committed
Added clikt examples (relates to #279)
1 parent 00b7b3b commit 5005e9f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

examples/clikt-example.kts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//@file:DependsOn("com.github.ajalt:clikt:2.7.1")
2+
@file:DependsOn("com.github.ajalt.clikt:clikt-jvm:3.0.1")
3+
4+
5+
import com.github.ajalt.clikt.core.CliktCommand
6+
import com.github.ajalt.clikt.parameters.options.default
7+
import com.github.ajalt.clikt.parameters.options.option
8+
import com.github.ajalt.clikt.parameters.options.prompt
9+
import com.github.ajalt.clikt.parameters.types.int
10+
11+
class Hello : CliktCommand() {
12+
val count: Int by option(help="Number of greetings").int().default(1)
13+
val name: String by option(help="The person to greet").prompt("Your name")
14+
15+
override fun run() {
16+
repeat(count) {
17+
echo("Hello $name!")
18+
}
19+
}
20+
}
21+
//@file:KotlinOpts("-J-Xmx5g")
22+
//@file:KotlinOpts("-J-server")
23+
//@file:CompilerOpts("-jvm-target 1.8")
24+
25+
Hello().main(args)
26+
//Startup.main(args)

0 commit comments

Comments
 (0)