diff --git a/main.go b/main.go index 81eec8c..135ed2e 100644 --- a/main.go +++ b/main.go @@ -1,3 +1,4 @@ +// Package main is the entrypoint package main import ( @@ -10,26 +11,11 @@ import ( ) func main() { - exec, err := os.Executable() - if err != nil { - panic(err) - } - - // running directly - if normalize(filepath.Base(exec)) == normalize(filepath.Base(os.Args[0])) || - !strings.Contains(filepath.Base(os.Args[0]), "sendmail") { - cmd.Execute() - } else { - // symlinked as "*sendmail*" + // if the command executable contains "send" in the name (eg: sendmail), then run the sendmail command + if strings.Contains(strings.ToLower(filepath.Base(os.Args[0])), "send") { sendmail.Run() + } else { + // else run mailpit + cmd.Execute() } } - -// Normalize returns a lowercase string stripped of the file extension (if exists). -// Used for detecting Windows commands which ignores letter casing and `.exe`. -// eg: "MaIlpIT.Exe" returns "mailpit" -func normalize(s string) string { - s = strings.ToLower(s) - - return strings.TrimSuffix(s, filepath.Ext(s)) -}