add --version to get the app current version

This commit is contained in:
AmirHossein Abdolmotallebi 2024-09-23 15:48:00 +03:30
parent 8ec33e1fa1
commit 0dc4c676ee
2 changed files with 11 additions and 0 deletions

View File

@ -58,6 +58,9 @@ fun main(args: Array<String>) {
AppArguments.init(args)
AppProperties.boot()
val appArguments = AppArguments.get()
if (appArguments.version) {
dispatchVersionAndExit()
}
val singleInstance = SingleInstanceUtil(AppInfo.configDir.toOkioPath())
if (appArguments.startIfNotStarted && !AppInfo.isInIDE()) {
startAndWaitForRunIfNotRunning(singleInstance)
@ -88,6 +91,11 @@ private fun startAppInAnotherProcess() {
Runtime.getRuntime().exec(cmd)
}
private fun dispatchVersionAndExit(): Nothing {
print(AppInfo.version)
exitProcess(0)
}
private fun dispatchIntegrationPortAndExit(singleInstance: SingleInstanceUtil): Nothing {
val port =
singleInstance.sendToInstance(Commands.getIntegrationPort)

View File

@ -5,6 +5,7 @@ data class AppArguments(
val startIfNotStarted: Boolean,
val startSilent: Boolean,
val debug: Boolean,
val version: Boolean,
) {
companion object {
private lateinit var instance: AppArguments
@ -23,6 +24,7 @@ data class AppArguments(
startIfNotStarted = args.contains(Args.START_IF_NOT_STARTED),
startSilent = args.contains(Args.BACKGROUND),
debug = args.contains(Args.DEBUG),
version = args.contains(Args.VERSION),
)
}
}
@ -32,5 +34,6 @@ data class AppArguments(
const val BACKGROUND = "--background"
const val GET_INTEGRATION_PORT = "--get-integration-port"
const val DEBUG = "--debug"
const val VERSION = "--version"
}
}