Skip to content

Commit

Permalink
Add print-log-path flag with early return
Browse files Browse the repository at this point in the history
  • Loading branch information
FIGBERT committed Sep 7, 2023
1 parent d8b1fb4 commit 85663fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -100,6 +101,11 @@ func main() {
debug.DeadlockDetection = true
debug.WriteLogs = true
}
if *printLogPath {
fmt.Println(debug.LogFile())
return
}

debug.Initialize()
defer debug.Recover()

Expand Down

0 comments on commit 85663fc

Please sign in to comment.