-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathclasspath_example.kts
executable file
·44 lines (32 loc) · 1.4 KB
/
classpath_example.kts
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
42
43
44
#!/usr/bin/env kscript
//DEPS com.offbytwo:docopt:0.6.0.20150202,log4j:log4j:1.2.14
//#!/usr/bin/env kotlinc -script -classpath /Users/brandl/.m2/repository/org/docopt/docopt/0.6.0-SNAPSHOT/docopt-0.6.0-SNAPSHOT.jar
import org.docopt.Docopt
import java.io.File
import java.util.*
// woraround for https://youtrack.jetbrains.com/issue/KT-13347
//val args = listOf("foo", "bar")
val usage ="""
kscript - Enhanced scripting support for Kotlin on *nix-based systems.
Usage:
kscript ( -t | --text ) <version>
kscript [ --interactive | --idea | --package ] [--] ( - | <file or URL> ) [<args>]...
kscript (-h | --help)
Options:
-t, --text Enable stdin support API for more streamlined text processing [default: latest]
--package Package script and dependencies into self-dependent binary
--idea boostrap IDEA from a kscript
-i, --interactive Create interactive shell with dependencies as declared in script
- Read script from the STDIN
-h, --help Print this text
--clear-cache Wipe cached script jars and urls
"""
val doArgs = Docopt(usage).parse(args.toList())
println("parsed args are: \n$doArgs (${doArgs.javaClass.simpleName})\n")
doArgs.forEach { (key: Any, value: Any) ->
println("$key:\t$value\t(${value?.javaClass?.canonicalName})")
}
println("\nHello from Kotlin!")
for (arg in args) {
println("arg: $arg")
}