Improve script cli diagnostics
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
||||
error: source file or directory not found: path/to/nonexistent.kts
|
||||
error: script file not found: path/to/nonexistent.kts; Specify path to the script file as the first argument
|
||||
COMPILATION_ERROR
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
error: specify path to the script file as the first argument
|
||||
error: script argument points to a directory: $TESTDATA_DIR$/wrongAbiVersionLib; Specify path to the script file as the first argument
|
||||
COMPILATION_ERROR
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
error: specify path to the script file as the first argument
|
||||
error: unrecognized script file: $TESTDATA_DIR$/simple.kt; Specify path to the script file as the first argument
|
||||
COMPILATION_ERROR
|
||||
|
||||
+8
-2
@@ -60,11 +60,17 @@ abstract class AbstractScriptEvaluationExtension : ScriptEvaluationExtension {
|
||||
val scriptFile = File(arguments.freeArgs.first())
|
||||
val script = scriptFile.toScriptSource()
|
||||
|
||||
if (scriptFile.isDirectory || !scriptDefinitionProvider.isScript(script)) {
|
||||
val error = when {
|
||||
!scriptFile.exists() -> "Script file not found: ${arguments.freeArgs.first()}"
|
||||
scriptFile.isDirectory -> "Script argument points to a directory: ${arguments.freeArgs.first()}"
|
||||
!scriptDefinitionProvider.isScript(script) -> "Unrecognized script file: ${arguments.freeArgs.first()}"
|
||||
else -> null
|
||||
}
|
||||
if (error != null) {
|
||||
val extensionHint =
|
||||
if (configuration.get(ScriptingConfigurationKeys.SCRIPT_DEFINITIONS)?.let { it.size == 1 && it.first().isDefault } == true) " (.kts)"
|
||||
else ""
|
||||
messageCollector.report(CompilerMessageSeverity.ERROR, "Specify path to the script file$extensionHint as the first argument")
|
||||
messageCollector.report(CompilerMessageSeverity.ERROR, "$error; Specify path to the script file$extensionHint as the first argument")
|
||||
return ExitCode.COMPILATION_ERROR
|
||||
}
|
||||
script
|
||||
|
||||
Reference in New Issue
Block a user