ioquatix / script-runner

This package will run various script files inside of Atom. It currently supports JavaScript, CoffeeScript, Ruby, and Python. You can add more.
http://atom.io/packages/script-runner
Other
62 stars 23 forks source link

Kotlin support #108

Closed codic12 closed 4 years ago

codic12 commented 4 years ago

I know that I can use a shebang... but then it won't be compatible with normal kotlin :(

ioquatix commented 4 years ago

Can you make a PR?

codic12 commented 4 years ago

I do not know where in the code this is located. But for reference kotlin goes thru a compilation step. Assuming you have hello.kt:

kotlinc hello.kt -include-runtime -d hello.jar # compile hello.kt to a jar file
java -jar hello.jar # run the jar file the same way as a java generated jar
huba commented 4 years ago

Kotlin is a compiled language like C or rust, however the Kotlin compiler, kotlinc, can work like an interpreter using the -script command line option. To use the Kotlin language this way, you will need to change the file extension to .kts and use the following shebang line.

#!/usr/bin/env -S kotlinc -script

One of the differences to normally compiling Kotlin is that this way your code's entry point will be the top of the .kts file, rather than the main function. This is probably one of the reasons for having a different file extension.

codic12 commented 4 years ago

I am aware of this

ioquatix commented 4 years ago

@gsbhasin123 I don't believe there is any reason why we would not accept a PR to fix this, so can you propose something?

ioquatix commented 4 years ago

https://github.com/ioquatix/script-runner/blob/d2ec19bfc8d4102dd09d8812b1cf3544d79060f1/lib/script-runner.js#L43-L53

Is at least the first place you'd need to modify.

codic12 commented 4 years ago

oh. Well all those languages are interpreted, so I'm not sure how I'd do it for a language that needs two commands (aka a compiled one)

ioquatix commented 4 years ago

Make a wrapper?

codic12 commented 4 years ago

I'm not sure how. Anyways, I moved away from script-runner temporarily because of the lack of input support.

ioquatix commented 4 years ago

Ok.