|
|
|
@ -8,6 +8,8 @@ import org.domaindrivenarchitecture.provs.desktop.infrastructure.getConfig
|
|
|
|
|
import org.domaindrivenarchitecture.provs.framework.core.cli.createProvInstance
|
|
|
|
|
import org.domaindrivenarchitecture.provs.framework.core.cli.quit
|
|
|
|
|
import java.io.FileNotFoundException
|
|
|
|
|
import java.nio.file.Files
|
|
|
|
|
import kotlin.io.path.Path
|
|
|
|
|
import kotlin.system.exitProcess
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -21,22 +23,28 @@ fun main(args: Array<String>) {
|
|
|
|
|
exitProcess(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val config = if (cmd.configFile == null) DesktopConfig() else
|
|
|
|
|
val defaultConfigFileName = "desktop-config.yaml"
|
|
|
|
|
val config = if ((cmd.configFile == null) && !Files.isRegularFile(Path(defaultConfigFileName))) {
|
|
|
|
|
println("ATTENTION: No config provided => using an empty config.")
|
|
|
|
|
DesktopConfig()
|
|
|
|
|
} else {
|
|
|
|
|
val configFileName = cmd.configFile?.fileName ?: defaultConfigFileName
|
|
|
|
|
try {
|
|
|
|
|
getConfig(cmd.configFile.fileName)
|
|
|
|
|
getConfig(configFileName)
|
|
|
|
|
} catch (e: SerializationException) {
|
|
|
|
|
println(
|
|
|
|
|
"Error: File \"${cmd.configFile.fileName}\" has an invalid format and or invalid data."
|
|
|
|
|
"Error: File \"${configFileName}\" has an invalid format and or invalid data."
|
|
|
|
|
)
|
|
|
|
|
null
|
|
|
|
|
} catch (e: FileNotFoundException) {
|
|
|
|
|
println(
|
|
|
|
|
"Error: File\u001b[31m ${cmd.configFile.fileName} \u001b[0m was not found.\n" +
|
|
|
|
|
"Pls copy file \u001B[31m desktop-config-example.yaml \u001B[0m to file \u001B[31m ${cmd.configFile.fileName} \u001B[0m " +
|
|
|
|
|
"Error: File\u001b[31m ${configFileName} \u001b[0m was not found.\n" +
|
|
|
|
|
"Pls copy file \u001B[31m desktop-config-example.yaml \u001B[0m to file \u001B[31m ${configFileName} \u001B[0m " +
|
|
|
|
|
"and change the content according to your needs."
|
|
|
|
|
)
|
|
|
|
|
null
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (config == null) {
|
|
|
|
|
println("No suitable config found.")
|
|
|
|
|