@@ -51,27 +51,26 @@ To use `kscript` just Kotlin is required.
5151To https://kotlinlang.org/docs/tutorials/command-line.html[install Kotlin] we
5252recommend http://sdkman.io/install[sdkman]:
5353
54+ [source,bash]
5455----
5556curl -s "https://get.sdkman.io" | bash # install sdkman
5657source "$HOME/.sdkman/bin/sdkman-init.sh" # add sdkman to PATH
5758
5859sdk install kotlin # install Kotlin
59-
6060----
6161
6262Once Kotlin is ready, you can install `kscript` with
6363
64+ [source,bash]
6465----
6566sdk install kscript
66-
6767----
6868
6969To test your installation simply run
7070
7171[source,bash]
7272----
7373kscript --help
74-
7574----
7675
7776This will check and inform about updates. To update `kscript` simply install it again as described above.
@@ -87,15 +86,13 @@ docker run -i holgerbrandl/kscript 'println("Hello, world!")'
8786
8887# or using versioned container
8988docker run -i holgerbrandl/kscript:2.9.3 'println("Hello, world!")'
90-
9189----
9290
9391To use a script file outside the container as input, you could do
9492
9593[source,bash]
9694----
9795docker run -i holgerbrandl/kscript - < script.kts
98-
9996----
10097
10198This will make `kscript` read the code from stdin while piping the file. Beware that the -i flag is needed to have
@@ -134,7 +131,7 @@ On Arch Linux, `kscript` is available through
134131the https://aur.archlinux.org/packages/kscript/[Arch Linux User repository (AUR)]. Use your
135132favorite https://wiki.archlinux.org/index.php/AUR_helpers[AUR helper] to install, e.g. `yay`:
136133
137- [source,shell ]
134+ [source,bash ]
138135----
139136yay -S kscript
140137----
@@ -145,7 +142,7 @@ Two workarounds for ArchLinux exists, which can be used to make 'kscript' workin
145142
146143. Manually create symlinks in the system…
147144+
148- [source,shell ]
145+ [source,bash ]
149146----
150147sudo mkdir /usr/share/kotlin/bin
151148sudo ln -s /usr/bin/kotlin /usr/share/kotlin/bin/kotlin
@@ -173,9 +170,9 @@ To build `kscript` yourself, simply clone the repo and do
173170
174171== Script Input Modes
175172
176- The main mode of operation is `kscript < script> `.
173+ The main mode of operation is `kscript < script> `.
177174
178- The `< script> ` can be a Kotlin `*.kts` script file , a script URL, `-` for stdin, a process substitution file handle,
175+ The `< script> ` can be a Kotlin `*.kts` script file , a script URL, `-` for stdin, a process substitution file handle,
179176a `*.kt` source file with a main method, or some kotlin code.
180177
181178=== Interpreter Usage
@@ -198,12 +195,14 @@ To use `kscript` in a workflow without creating an additional script file, you c
198195for _inlined usage_. The following modes are supported:
199196
200197* Directly provide a Kotlin scriptlet as argument
198+
201199[source,bash]
202200----
203201kscript 'println("hello world")'
204202----
205203
206204* Pipe a Kotlin snippet into `kscript` and instruct it to read from `stdin` by using `-` as script argument
205+
207206[source,bash]
208207----
209208echo 'println("Hello Kotlin.")' | kscript -
219218----
220219
221220* Since the piped content is considered as a regular script it can also have dependencies
221+
222222[source,bash]
223223----
224224kscript - <<"EOF"
232232----
233233
234234* Finally, (for sake of completeness), it also works with process substitution and for sure you can always provide
235- additional arguments (exposed as `args : Array< String> ` within the script)
235+ additional arguments (exposed as `args : Array< String> ` within the script)
236236
237237[source,bash]
238238----
@@ -466,7 +466,7 @@ cat some_file | kscript -t 'lines
466466----
467467
468468In this example, the extension
469- method https://github.com/holgerbrandl/kscript-support-api/blob/master/src/main/kotlin/kscript/text/StreamUtil.kt#L34[`Iterable< String> .print()`]
469+ method https://github.com/holgerbrandl/kscript-support-api/blob/master/src/main/kotlin/kscript/text/StreamUtil.kt#L34[`Iterable< String> .print()`]
470470to print the lines to stdout comes from the support API. The rest is stdlib Kotlin.
471471
472472For more examples using the support library see
@@ -516,7 +516,7 @@ Welcome to Kotlin version 1.1.51 (JRE 1.8.0_151-b12)
516516
517517Artifacts and versions will differ between scripts, so it is hard to maintain them all in a single project. To
518518nevertheless provide optimal tooling when scripting with Kotlin `kscript` allows to create temporary projects
519- for `< script> ` arguments.
519+ for `< script> ` arguments.
520520
521521[source,bash]
522522----
@@ -525,7 +525,7 @@ kscript --idea CountRecords.kts
525525
526526If you have available `gradle` in the path project will be automatically built and if there is `idea` in the path
527527the project will be opened in https://www.jetbrains.com/idea/[IntelliJ IDEA] with a minimalistic project containing
528- just your (1) `< script> ` and (2) a generated `build.gradle.kts` file:
528+ just your (1) `< script> ` and (2) a generated `build.gradle.kts` file:
529529
530530image:misc/readme_images/minus_idea.png[]
531531
0 commit comments