diff --git a/examples/classpath_example.kts b/examples/classpath_example.kts index 6b031304..8e6fddd4 100755 --- a/examples/classpath_example.kts +++ b/examples/classpath_example.kts @@ -1,4 +1,5 @@ #!/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 @@ -11,34 +12,35 @@ import java.util.* // woraround for https://youtrack.jetbrains.com/issue/KT-13347 //val args = listOf("foo", "bar") - -var test = File("sdf") -val usage = """ -Usage: jl [options] [] - -Supported commands are - submit Submits a job to the underlying queuing system and adds it to the list - add Extracts job-ids from stdin and adds them to the list - wait Wait for a list of jobs to finish - status Prints various statistics and allows to create an html report for the list - kill Removes all jobs of this list from the scheduler queue - up Moves a list of jobs to the top of a queue (if supported by the underlying scheduler) - reset Removes all information related to this joblist. - -If no is provided, jl will use '.jobs' as default +val usage =""" +kscript - Enhanced scripting support for Kotlin on *nix-based systems. + +Usage: + kscript ( -t | --text ) + kscript [ --interactive | --idea | --package ] [--] ( - | ) []... + kscript (-h | --help) + kscript ( --self-update | --clear-cache ) + +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 + --self-update Update kscript to the latest version + --clear-cache Wipe cached script jars and urls """ -val doArgs = Docopt(usage). - parse(args.toList()). - map { it -> - it.key.removePrefix("--").replace("[<>]", "") to { - if (it.value == null) null else Objects.toString(it.value) - } - } +val doArgs = Docopt(usage).parse(args.toList()) + +println("parsed args are: \n$doArgs (${doArgs.javaClass.simpleName})\n") -println("parsed args are: \n" + doArgs) +doArgs.forEach { (key: Any, value: Any) -> + println("$key:\t$value\t(${value?.javaClass?.canonicalName})") +} -println("Hello from Kotlin!") +println("\nHello from Kotlin!") for (arg in args) { println("arg: $arg") }