Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include/Import local file dependency #34

Closed
xgouchet opened this issue Aug 2, 2017 · 6 comments
Closed

Include/Import local file dependency #34

xgouchet opened this issue Aug 2, 2017 · 6 comments
Assignees

Comments

@xgouchet
Copy link

xgouchet commented Aug 2, 2017

In a project, I have multiple kotlin script files, and I have some methods I need to use in most, if not all script.

Is there an existing way to write these method in a single external file, and include it from the other scripts ?

eg :
utils.kts

fun foo(s : String) : String {
  //...
}

myscript.kts

#!/usr/bin/env kscript

//INCLUDE utils.kts

foo(args[0])
@holgerbrandl
Copy link
Collaborator

Nice idea, and it seems easy to do.

But how do you write those scripts? Since the IDE won't resolve //INCLUDE you'll get tons of red code, don't you?

@holgerbrandl
Copy link
Collaborator

I've implemented it in a separate branch for now. See https://github.com/holgerbrandl/kscript/blob/include_directive/test/resources/includes/include_variations.kts for an example. Feel welcome to let me know what you think.

@xgouchet
Copy link
Author

That seems perfect for what I want !

@holgerbrandl
Copy link
Collaborator

I'm still skeptical if it makes sense to include it into the release branch because of missing IDE support. All the included bits will light up in bright red in the master script. How would you code them efficiently without pain?

@Bwvolleyball
Copy link

Was anything ever decided as to how to add IDE support for //INCLUDE files?

@holgerbrandl
Copy link
Collaborator

In general, the feature has been added, see https://github.com/holgerbrandl/kscript#ease-prototyping-with-include.

Except for IDE support, which would require a separate plugin. However, its fairly easy to configure the IDE accordingly in my experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants