github.com/wtfutil/wtf@v0.43.0/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "log" 6 "os" 7 8 // Blank import of tzdata embeds the timezone database to allow Windows hosts to find timezone 9 // information even if the timezone database is not available on the local system. See release 10 // notes at https://golang.org/doc/go1.15#time/tzdata for details. This prevents "no timezone 11 // data available" errors in clocks module. 12 _ "time/tzdata" 13 14 "github.com/logrusorgru/aurora/v4" 15 "github.com/pkg/profile" 16 17 "github.com/wtfutil/wtf/app" 18 "github.com/wtfutil/wtf/cfg" 19 "github.com/wtfutil/wtf/flags" 20 "github.com/wtfutil/wtf/utils" 21 "github.com/wtfutil/wtf/wtf" 22 ) 23 24 /* -------------------- Main -------------------- */ 25 26 func main() { 27 log.SetFlags(log.LstdFlags | log.Lshortfile) 28 29 // Parse and handle flags 30 flags := flags.NewFlags() 31 flags.Parse() 32 33 // Load the configuration file 34 cfg.Initialize(flags.HasCustomConfig()) 35 config := cfg.LoadWtfConfigFile(flags.ConfigFilePath()) 36 37 wtf.SetTerminal(config) 38 39 flags.RenderIf(config) 40 41 if flags.Profile { 42 defer profile.Start(profile.MemProfile).Stop() 43 } 44 45 openFileUtil := config.UString("wtf.openFileUtil", "open") 46 openURLUtil := utils.ToStrs(config.UList("wtf.openUrlUtil", []interface{}{})) 47 utils.Init(openFileUtil, openURLUtil) 48 49 /* Initialize the App Manager */ 50 appMan := app.NewAppManager() 51 appMan.MakeNewWtfApp(config, flags.Config) 52 53 currentApp, err := appMan.Current() 54 if err != nil { 55 fmt.Printf("\n%s %v\n", aurora.Red("ERROR"), err) 56 os.Exit(1) 57 } 58 59 err = currentApp.Execute() 60 if err != nil { 61 fmt.Printf("\n%s %v\n", aurora.Red("ERROR"), err) 62 os.Exit(1) 63 } 64 }