From 85663fccc7d0f15ae7ae2f0e4677e0b6a45e0e00 Mon Sep 17 00:00:00 2001 From: FIGBERT Date: Thu, 7 Sep 2023 09:58:59 -0700 Subject: [PATCH] Add print-log-path flag with early return --- debug/debug.go | 4 ++++ main.go | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/debug/debug.go b/debug/debug.go index f350124..138e5a3 100644 --- a/debug/debug.go +++ b/debug/debug.go @@ -64,6 +64,10 @@ func getUname() string { return currUser.Username } +func LogFile() string { + return filepath.Join(LogDirectory, "debug.log") +} + func Initialize() { err := os.MkdirAll(LogDirectory, 0750) if err != nil { diff --git a/main.go b/main.go index 362263d..6422140 100644 --- a/main.go +++ b/main.go @@ -70,13 +70,14 @@ var MainUIProvider ifc.UIProvider = ui.NewGomuksUI var wantVersion = flag.MakeFull("v", "version", "Show the version of gomuks", "false").Bool() var clearCache = flag.MakeFull("c", "clear-cache", "Clear the cache directory instead of starting", "false").Bool() var skipVersionCheck = flag.MakeFull("s", "skip-version-check", "Skip the homeserver version checks at startup and login", "false").Bool() +var printLogPath = flag.MakeFull("l", "print-log-path", "Print the log path instead of starting", "false").Bool() var clearData = flag.Make().LongKey("clear-all-data").Usage("Clear all data instead of starting").Default("false").Bool() var wantHelp, _ = flag.MakeHelpFlag() func main() { flag.SetHelpTitles( "gomuks - A terminal Matrix client written in Go.", - "gomuks [-vcsh] [--clear-all-data|--log-in-for-transfer]", + "gomuks [-vcsh] [--clear-all-data|--print-log-path]", ) err := flag.Parse() if err != nil { @@ -100,6 +101,11 @@ func main() { debug.DeadlockDetection = true debug.WriteLogs = true } + if *printLogPath { + fmt.Println(debug.LogFile()) + return + } + debug.Initialize() defer debug.Recover()