2024-09-16 20:31:15 +09:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"text/tabwriter"
|
2024-09-22 00:29:36 +09:00
|
|
|
|
2024-10-21 20:47:02 +09:00
|
|
|
"git.ophivana.moe/security/fortify/internal/fmsg"
|
2024-10-20 19:50:13 +09:00
|
|
|
"git.ophivana.moe/security/fortify/internal/state"
|
2024-09-16 20:31:15 +09:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2024-09-22 00:29:36 +09:00
|
|
|
stateActionEarly bool
|
2024-09-16 20:31:15 +09:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2024-09-22 00:29:36 +09:00
|
|
|
flag.BoolVar(&stateActionEarly, "state", false, "print state information of active launchers")
|
2024-09-16 20:31:15 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
// tryState is called after app initialisation
|
|
|
|
func tryState() {
|
2024-09-22 00:29:36 +09:00
|
|
|
if stateActionEarly {
|
|
|
|
var w *tabwriter.Writer
|
2024-10-23 21:46:21 +09:00
|
|
|
state.MustPrintLauncherStateSimpleGlobal(&w, os.Paths().RunDirPath)
|
2024-09-22 00:29:36 +09:00
|
|
|
if w != nil {
|
|
|
|
if err := w.Flush(); err != nil {
|
2024-10-21 20:47:02 +09:00
|
|
|
fmsg.Println("cannot format output:", err)
|
2024-09-22 00:29:36 +09:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fmt.Println("No information available")
|
2024-09-16 20:31:15 +09:00
|
|
|
}
|
|
|
|
|
2024-10-26 23:09:32 +09:00
|
|
|
fmsg.Exit(0)
|
2024-09-22 00:29:36 +09:00
|
|
|
}
|
2024-09-16 20:31:15 +09:00
|
|
|
}
|