kscripting / kscript

Scripting enhancements for Kotlin
MIT License
2.07k stars 124 forks source link

With 4.1.1 version of Kscript, need import root function or will broken #377

Closed wuseal closed 2 years ago

wuseal commented 2 years ago

Hi, I tested with 4.1.1, there is a behavior that I think not the same like before

run kscript https://raw.githubusercontent.com/wuseal/Scripts/main/test.kts script code

@file:DependsOn("com.sealwu:kscript-tools:1.0.2")
"ls".runCommand()

with failed information

[kscript] [ERROR] Exit Code   : 1   
[kscript] [ERROR] Stdout      : ''
[kscript] [ERROR] Stderr      : '/Users/haibao/.cache/kscript/jar_3592325632d88f4324f2326b81bd87b2/Test.kts:3:6: error: unresolved reference: runCommand[nl]"ls".runCommand()[nl]     ^[nl]'
[kscript] [ERROR] 

run kscript https://raw.githubusercontent.com/wuseal/Scripts/main/testOk.kts script code:

@file:DependsOn("com.sealwu:kscript-tools:1.0.2")
import runCommand
"ls".runCommand()

works fine, the difference is that one more code

import runCommand

For kotlin standard syntax, I think no need to import root function that without package declarations

How do you think?

aartiPl commented 2 years ago

In this case, I would keep the import. I plan to do one more big rework in kscript so that refactoring might resolve this issue.