mirror of
https://github.com/amir1376/ab-download-manager.git
synced 2025-02-20 11:43:24 +08:00
add --version to get the app current version
This commit is contained in:
parent
8ec33e1fa1
commit
0dc4c676ee
@ -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)
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user