File tree Expand file tree Collapse file tree 5 files changed +28
-8
lines changed
simple-main-kts/simple-main-kts-test/testData Expand file tree Collapse file tree 5 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,11 @@ or even as simple as
4040./script.main.kts
4141```
4242
43- provided that the shebang line is added to the script and works in the given OS shell. * (See examples below.)*
43+ provided that the shebang line is added to the script and works in the given OS shell
44+
45+ ```
46+ #!/usr/bin/env kotlin
47+ ```
4448
4549### Caching
4650
@@ -60,4 +64,12 @@ including navigation into imported libraries.
6064[ ` kotlinx-html ` library] ( https://github.com/Kotlin/kotlinx.html ) by JetBrains, to generate HTML output
6165- [ ` kotlin-shell.main.kts ` ] ( scripts/kotlin-shell.main.kts ) demonstrates usage of the
6266[ ` kotlin-shell ` library] ( https://github.com/jakubriegel/kotlin-shell ) by Jakub Riegel, to execute OS shell commands
63- with easy interaction with Kotlin code
67+ with easy interaction with Kotlin code and can be executed:
68+
69+ - without arguments - executes "ls -l" command for curren directory
70+ - with argument - executes "wc" command for a file
71+
72+ ```
73+ kotlin kotlin-shell.main.kts main-kts/example.txt
74+ ```
75+
Original file line number Diff line number Diff line change 1+ Two roads diverged in a yellow wood,
2+ And sorry I could not travel both
3+ And be one traveler, long I stood
4+ And looked down one as far as I could
5+ To where it bent in the undergrowth.
Original file line number Diff line number Diff line change 11#! / usr/ bin/ env kotlin
22
33@file:DependsOn(" eu.jrie.jetbrains:kotlin-shell-core:0.2.1" )
4- @file:DependsOn(" org.slf4j:slf4j-simple:1.7.28" )
54@file:CompilerOptions(" -Xopt-in=kotlin.RequiresOptIn" )
65@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi ::class )
6+ @file:Suppress(" OPT_IN_ARGUMENT_IS_NOT_MARKER" )
77
8- import eu.jrie.jetbrains.kotlinshell.shell.*
8+
9+ import eu.jrie.jetbrains.kotlinshell.shell.shell
910
1011shell {
1112 if (args.isEmpty()) {
13+ " echo this is 'ls -l' command for current directory: ${env(" PWD" )} " ()
1214 " ls -l" ()
1315 } else {
1416 var lines = 0
1517 var words = 0
1618 var chars = 0
1719
18- var wasSpace = false
20+ var wasSpace = true
1921
2022 pipeline {
2123 " cat ${args[0 ]} " .process() pipe
@@ -38,7 +40,7 @@ shell {
3840 }
3941
4042 println (" My wc:" )
41- println (" $lines $words $chars " )
43+ println (" $lines $words $chars ${args[ 0 ]} " )
4244 println (" System wc:" )
4345 " wc ${args[0 ]} " ()
4446 }
Original file line number Diff line number Diff line change 22
33@file:DependsOn(" org.jetbrains.kotlinx:kotlinx-html-jvm:0.8.0" )
44
5- import kotlinx.html.*; import kotlinx.html.stream.* ; import kotlinx.html.attributes.*
5+ import kotlinx.html.*
6+ import kotlinx.html.stream.createHTML
67
78val addressee = args.firstOrNull() ? : " World"
89
Original file line number Diff line number Diff line change 11#! / usr/ bin/ env kotlinc - cp dist/ kotlinc/ lib/ kotlin- main- kts.jar - script
22
33@file:Repository(" https://jcenter.bintray.com" )
4- @file:DependsOn(" org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.11 " )
4+ @file:DependsOn(" org.jetbrains.kotlinx:kotlinx-html-jvm:0.8.0 " )
55
66import kotlinx.html.*; import kotlinx.html.stream.* ; import kotlinx.html.attributes.*
77
You can’t perform that action at this time.
0 commit comments