are there any kotlin libraries for creating Comman...
# announcements
s
are there any kotlin libraries for creating Command Line Shells from, as i cant find any online, just stuff about kotlin compiler and the kotlin REPL
g
what do you mean? You compile kotlin and run jar, there is application plugin in Gradle that generates those scripts
s
i mean something like this
Copy code
class REPL {
    val ENV = init()
        .also {
            parse("#define VERSION ${preprocessor.base.globalVariables.version}", it)
        }
        .also {
            parse("#define PS1 $", it)
        }

    fun promt() {
        print(parse("PS1", ENV) + " ")
    }

    fun promt(PS1: String) {
        print("$PS1 ")
    }

    fun REPL() {
        // TODO make a proper REPL
        println(parse("Kotlin Pre Processor Version VERSION", ENV))
        macroList(ENV)
        promt()
        var line = readLine()
        while (line != null) {
            println(parse(line, m, newlineFunction = {
                promt()
                val x = readLine()
                if (x != null) x
                else abort("failed to grab a new line")
            }))
            promt()
            line = readLine()
        }
    }
}
g
like this
like what exactly?
in general you can implement some simple REPL, what is your problem exactly?
s
im looking for a more complete REPL similar to that of an actual shell
g
not sure what is your goal, but there are some examples in
kotlinc
which provide Kotlin REPL, also there is also experimental Sparklin REPL console for Spark written on Kotlin
s
basically i want to create my own posix like shell/repl
g
Yes, but you say “more complete”, it’s pretty wide description
not sure that you can find any ready-to-use shell on Kotlin, it’s very specific use case
s
https://kotlinlang.slack.com/archives/C0922A726/p1555496443284500?thread_ts=1555488439.275100&cid=C0922A726 for example, one that provides most of the things that bash does such as heredoc support, function definition, aliasing, piping, redirection, and so on
g
Yeah, I understand, not sure that you can find anything like this, because I cannot imagine why would it may be useful for someone if you do not write general-usage shell