6

Here is a simple script

fun main() {
    print("ready> ")
    val input = readLine()
    println("User input: $input")
}

When I run this program with gradle runReleaseExecutableMacos I expect that I'll see a ready> prompt and will have a possibility to type some chars. But this program finishes immediately with User input: null as a result.

Am I missing something?

1
  • readLine() ==> readLine()!! Commented Jul 14, 2019 at 23:47

1 Answer 1

5

To achieve the behavior you desire, you can run the executable file produced by the Gradle. It will have an extension *.kexe.


Also, you can extend your build.gradle file with additional parameter. you got to add something like this:

macosX64("macos") {
    binaries {
        executable {
            runTask.standardInput = System.in
        }
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

use ticks around 'in' ``` macosX64("macos") { binaries { executable { runTask?.standardInput = System.in } } } ```

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.