@@ -40,7 +40,7 @@ kotlin scripting interpreter.
4040- [ Script Configuration] ( #script-configuration )
4141- [ Text Processing Mode] ( #text-processing-mode )
4242- [ Treat yourself a REPL with ` --interactive ` ] ( #treat-yourself-a-repl-with---interactive )
43- - [ Boostrap IDEA from a ` kscript ` let ] ( #boostrap-idea-from-a-kscriptlet )
43+ - [ Boostrap IDEA from a scriptlet ] ( #boostrap-idea-from-a-scriptlet )
4444- [ Deploy scripts as standalone binaries] ( #deploy-scripts-as-standalone-binaries )
4545- [ Embed kscript installer within your script] ( #embed-kscript-installer-within-your-script )
4646- [ KScript configuration file] ( #kscript-configuration-file )
@@ -105,7 +105,8 @@ instance [bind mounts](https://docs.docker.com/storage/bind-mounts/).
105105#### Installation without ` sdkman `
106106
107107If you have Kotlin already, and you would like to install the latest ` kscript ` release without using ` sdkman `
108- you can do so by unzipping the [ latest ] ( https://github.com/holgerbrandl/kscript/releases/latest ) binary release. Don't forget to update your ` $PATH ` accordingly.
108+ you can do so by unzipping the [ latest ] ( https://github.com/holgerbrandl/kscript/releases/latest ) binary release. Don't
109+ forget to update your ` $PATH ` accordingly.
109110
110111#### Installation with Homebrew
111112
@@ -132,6 +133,23 @@ favorite [AUR helper](https://wiki.archlinux.org/index.php/AUR_helpers) to insta
132133yay -S kscript
133134```
134135
136+ There is an uncommon directory layout of Kotlin package for Arch Linux, which causes problems when using kscript with
137+ default Kotlin package.
138+ Two workarounds for ArchLinux exists, which can be used to make 'kscript' working with ArchLinux:
139+
140+ 1 . Manually create symlinks in the system:
141+
142+ ``` shell
143+ sudo mkdir /usr/share/kotlin/bin
144+ sudo ln -s /usr/bin/kotlin /usr/share/kotlin/bin/kotlin
145+ sudo ln -s /usr/bin/kotlinc /usr/share/kotlin/bin/kotlinc
146+ ```
147+ 2. Install Kotlin using SdkMan:
148+ [Installation of SdkMan](# installation)
149+
150+ The problem should be fixed in the Kotlin package for ArchLinux. See more in the Github issue:
151+ https://github.com/kscripting/kscript/issues/371
152+
135153# ### Build it yourself
136154
137155To build ` kscript` yourself, simply clone the repo and do
@@ -279,12 +297,14 @@ println("Hello from Kotlin!")
279297println("Parsed script arguments are: \n" + doArgs)
280298```
281299
282- ` kscript ` will read dependencies from all lines in a script that start with ` @file:DependsOn ` (if any). Multiple dependencies can
300+ `kscript` will read dependencies from all lines in a script that start with `@file:DependsOn` (if any). Multiple
301+ dependencies can
283302be split by comma, space or semicolon.
284303
285304### Configure the runtime with `@file:KotlinOptions`
286305
287- ` kscript ` allows to provide a ` @file:KotlinOptions ` directive followed by parameters passed on to ` kotlin ` similar to how
306+ `kscript` allows to provide a `@file:KotlinOptions` directive followed by parameters passed on to `kotlin` similar to
307+ how
288308dependencies are defined:
289309
290310```kotlin
@@ -298,7 +318,8 @@ Note: Similar to the runtime you can also tweak the compile step by providing `@
298318
299319### Ease prototyping with `@file:Import`
300320
301- ` kscript ` supports an ` @file:Import ` directive to directly include other source files without prior compilation. Absolute
321+ `kscript` supports an `@file:Import` directive to directly include other source files without prior compilation.
322+ Absolute
302323and relative paths, as well as URLs are supported. Example:
303324
304325```kotlin
@@ -359,7 +380,7 @@ The latter is the default for `kt` files and could be omitted
359380#! /usr/bin/env kscript
360381
361382// Declare dependencies
362- @file:DependsOn(" com.github.holgerbrandl:kutils:0.12" )
383+ @file:DependsOn(" com.github.holgerbrandl:kutils:0.12" )
363384@file:DependsOn(" com.beust:klaxon:0.24" , " com.github.kittinunf.fuel:fuel:2.3.1" )
364385
365386// To use a custom maven repository you can declare it with
@@ -380,8 +401,8 @@ The latter is the default for `kt` files and could be omitted
380401@file:Import("util.kt")
381402
382403// Define kotlin options
383- @file:KotlinOptions(" -J-Xmx5g" )
384- @file:KotlinOptions(" -J-server" )
404+ @file:KotlinOptions("-J-Xmx5g")
405+ @file:KotlinOptions("-J-server")
385406@file:CompilerOptions("-jvm-target 1.8")
386407
387408// declare application entry point (applies on for kt-files)
@@ -472,7 +493,7 @@ Welcome to Kotlin version 1.1.51 (JRE 1.8.0_151-b12)
472493>>>
473494` ` `
474495
475- Boostrap IDEA from a ` kscript ` let
496+ Boostrap IDEA from a scriptlet
476497-----------------------------------
477498
478499Artifacts and versions will differ between scripts, so it is hard to maintain them all in a single project. To
@@ -483,14 +504,14 @@ for `<script>` arguments.
483504kscript --idea CountRecords.kts
484505` ` `
485506
486- If you have available ` gradle ` in the path project will be automatically built and if there is ` idea ` in the path
487- the project will be opened in [ IntelliJ IDEA] ( https://www.jetbrains.com/idea/ ) with a minimalistic project containing
507+ If you have available ` gradle` in the path project will be automatically built and if there is ` idea` in the path
508+ the project will be opened in [IntelliJ IDEA](https://www.jetbrains.com/idea/) with a minimalistic project containing
488509just your (1) ` < script> ` and (2) a generated ` build.gradle.kts` file:
489510
490511! [](misc/readme_images/minus_idea.png)
491512
492- The ` idea ` command line launcher can can be created in IntelliJ with ` Create Command-line Launcher ` command, or you can
493- set the command used to launch your IntelliJ as ` KSCRIPT_COMMAND_IDEA ` env property. Similarly, you can set ` gradle `
513+ The ` idea` command line launcher can can be created in IntelliJ with ` Create Command-line Launcher` command, or you can
514+ set the command used to launch your IntelliJ as ` KSCRIPT_COMMAND_IDEA` env property. Similarly, you can set ` gradle`
494515command using ` KSCRIPT_COMMAND_GRADLE` env property.
495516
496517Deploy scripts as standalone binaries
@@ -523,7 +544,7 @@ the [Installation](#installation) steps first.
523544
524545Note that unlike the [` --package` option](# deploy-scripts-as-standalone-binaries) this doesn't produce a separate file,
525546allowing the distributed script to be read and modified(including
526- with [ ` kscript --idea ` ] ( #boostrap-idea-from-a-kscriptlet ) ) similar to what you might expect with bash/python/ruby
547+ with [` kscript --idea` ](# boostrap-idea-from-a-scriptlet )) similar to what you might expect with bash/python/ruby
527548scripts.
528549On the other hand this doesn' t embed dependencies within the script("fat jar"), so internet connection may be required
529550on its first run.
@@ -533,14 +554,17 @@ kscript configuration file
533554
534555To keep some options stored permanently in configuration you can create kscript configuration file.
535556
536- KScript follows XDG directory standard, so the file should be created in:
537-
557+ KScript follows XDG directory standard, so the file should be created in (paths are resolved in provided order; first
558+ existing path is used):
538559
539- | OS | PATH |
540- | -------------| -------------------------------------------------------------------------------------|
541- | ** Windows** | %LOCALAPPDATA%\kscript.properties |
542- | ** Posix** | \\ ${XDG_CONFIG_DIR}/kscript.properties or \\ ${user.home}/.config/kscript.properties |
560+ | OS | PATH |
561+ |-------------|---------------------------------------------------------------------------------------------------|
562+ | **Windows** | %LOCALAPPDATA%\kscript\kscript.properties; %USERPROFILE%\.config\kscript\kscript.properties |
563+ | **MacOs** | ~/Library/Application Support/kscript/kscript.properties; |
564+ | **Posix** | \\${XDG_CONFIG_DIR}/kscript/kscript.properties; \\${user.home}/.config/kscript/kscript.properties |
543565
566+ If the environment variable: **KSCRIPT_DIRECTORY** is defined the configuration file ' kscript.properties' will be placed
567+ directly inside it.
544568
545569Content of kscript.properties file is a standard Java format, with following properties available:
546570
@@ -550,6 +574,7 @@ scripting.kotlin.opts=
550574scripting.repository.url=
551575scripting.repository.user=
552576scripting.repository.password=
577+ scripting.directory.artifacts=
553578```
554579
555580Example configuration file:
@@ -594,11 +619,12 @@ is a valid Kotlin `kts` script. Plain and simple, no `main`, no `companion`, jus
594619
595620### Does `kscript` also work for regular kotlin `.kt` source files with a `main` as entry point?
596621
597- Yes, (since kscript v1.6) you can run kotlin source files through ` kscript ` . By default, it will assume a top-level ` main ` method
622+ Yes, (since kscript v1.6) you can run kotlin source files through `kscript`. By default, it will assume a
623+ top-level `main` method
598624as entry-point.
599625
600- However, in case you're using a companion object to declare the entry point, you need to indicate this via the ` @file:Entry ` .
601-
626+ However, in case you' re using a companion object to declare the entry point, you need to indicate this via
627+ the ` @file:Entry ` .
602628
603629# ## What are performance and resource usage difference between scripting with kotlin and python?
604630
0 commit comments