-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello-qr.kt
executable file
·34 lines (28 loc) · 1.11 KB
/
hello-qr.kt
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
#!/bin/bash
//usr/bin/env echo '
/**** BOOTSTRAP kscript ****\'>/dev/null
command -v kscript >/dev/null 2>&1 || curl -L "https://git.io/fpF1K" | bash 1>&2
exec kscript $0 "$@"
\*** IMPORTANT: Any code including imports and annotations must come after this line ***/
@file:DependsOn("com.github.ajalt:clikt:2.1.0")
@file:DependsOn("com.google.zxing:core:3.4.0")
@file:Include("qr-lib.kt")
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.prompt
import java.util.concurrent.TimeUnit
class Hello : CliktCommand() {
private val name by option("-n", "--name", help = "Who are you happy to see").prompt("Host name")
private val ui by option("--ui").flag(default = false)
override fun run() {
if (ui) {
val file = "qr.png"
name.renderUi(file)
ProcessBuilder("open", file).start().waitFor(10, TimeUnit.SECONDS)
} else {
name.renderCli()
}
}
}
fun main(args: Array<String>) = Hello().main(args)