File tree 5 files changed +28
-8
lines changed
simple-main-kts/simple-main-kts-test/testData
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
40
40
./script.main.kts
41
41
```
42
42
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
+ ```
44
48
45
49
### Caching
46
50
@@ -60,4 +64,12 @@ including navigation into imported libraries.
60
64
[ ` kotlinx-html ` library] ( https://github.com/Kotlin/kotlinx.html ) by JetBrains, to generate HTML output
61
65
- [ ` kotlin-shell.main.kts ` ] ( scripts/kotlin-shell.main.kts ) demonstrates usage of the
62
66
[ ` 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 1
1
#! / usr/ bin/ env kotlin
2
2
3
3
@file:DependsOn(" eu.jrie.jetbrains:kotlin-shell-core:0.2.1" )
4
- @file:DependsOn(" org.slf4j:slf4j-simple:1.7.28" )
5
4
@file:CompilerOptions(" -Xopt-in=kotlin.RequiresOptIn" )
6
5
@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi ::class )
6
+ @file:Suppress(" OPT_IN_ARGUMENT_IS_NOT_MARKER" )
7
7
8
- import eu.jrie.jetbrains.kotlinshell.shell.*
8
+
9
+ import eu.jrie.jetbrains.kotlinshell.shell.shell
9
10
10
11
shell {
11
12
if (args.isEmpty()) {
13
+ " echo this is 'ls -l' command for current directory: ${env(" PWD" )} " ()
12
14
" ls -l" ()
13
15
} else {
14
16
var lines = 0
15
17
var words = 0
16
18
var chars = 0
17
19
18
- var wasSpace = false
20
+ var wasSpace = true
19
21
20
22
pipeline {
21
23
" cat ${args[0 ]} " .process() pipe
@@ -38,7 +40,7 @@ shell {
38
40
}
39
41
40
42
println (" My wc:" )
41
- println (" $lines $words $chars " )
43
+ println (" $lines $words $chars ${args[ 0 ]} " )
42
44
println (" System wc:" )
43
45
" wc ${args[0 ]} " ()
44
46
}
Original file line number Diff line number Diff line change 2
2
3
3
@file:DependsOn(" org.jetbrains.kotlinx:kotlinx-html-jvm:0.8.0" )
4
4
5
- import kotlinx.html.*; import kotlinx.html.stream.* ; import kotlinx.html.attributes.*
5
+ import kotlinx.html.*
6
+ import kotlinx.html.stream.createHTML
6
7
7
8
val addressee = args.firstOrNull() ? : " World"
8
9
Original file line number Diff line number Diff line change 1
1
#! / usr/ bin/ env kotlinc - cp dist/ kotlinc/ lib/ kotlin- main- kts.jar - script
2
2
3
3
@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 " )
5
5
6
6
import kotlinx.html.*; import kotlinx.html.stream.* ; import kotlinx.html.attributes.*
7
7
You can’t perform that action at this time.
0 commit comments