GODT-1671: Implement Quit & Restart mechanism

This commit is contained in:
Romain LE JEUNE
2022-07-28 16:39:56 +02:00
committed by Jakub
parent f44d1c4b9d
commit 22a8aab151
26 changed files with 1255 additions and 701 deletions

View File

@ -38,6 +38,10 @@ func (b *Base) restartApp(crash bool) error {
args = os.Args[1:]
}
if b.launcher != "" {
args = forceLauncherFlag(args, b.launcher)
}
logrus.
WithField("command", b.command).
WithField("args", args).
@ -78,3 +82,29 @@ func incrementRestartFlag(args []string) []string {
return res
}
// forceLauncherFlag replace or add the launcher args with the one set in the app.
func forceLauncherFlag(args []string, launcher string) []string {
res := append([]string{}, args...)
hasFlag := false
for k, v := range res {
if v != "--launcher" {
continue
}
if k+1 >= len(res) {
continue
}
hasFlag = true
res[k+1] = launcher
}
if !hasFlag {
res = append(res, "--launcher", launcher)
}
return res
}