1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/main.go
Chris Cummer fd794707cd
☢️ WTF-1031 Support multiple simultaneous configurations (#1032)
* WTF-1031 Rename WtfApp.app to WtfApp.tviewApp

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-1031 Add scaffolding for main to support multiple WtfApp instances

Signed-off-by: Chris Cummer <chriscummer@me.com>

* WTF-1031 WIP

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Remove common functionality from KeyboardWidget and into Base

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Augment with some descriptive comments

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Add full support for multiple app instances via the AppManager.

Still to do:

* Config support for multiple apps/multiple config files
* The ability to switch between apps

Signed-off-by: Chris Cummer <chriscummer@me.com>

* Move SetTerminal out of main and into its own file

Signed-off-by: Chris Cummer <chriscummer@me.com>
2020-12-21 03:25:41 -08:00

66 lines
1.5 KiB
Go

package main
import (
"fmt"
"log"
"os"
// Blank import of tzdata embeds the timezone database to allow Windows hosts to find timezone
// information even if the timezone database is not available on the local system. See release
// notes at https://golang.org/doc/go1.15#time/tzdata for details. This prevents "no timezone
// data available" errors in clocks module.
_ "time/tzdata"
"github.com/logrusorgru/aurora"
"github.com/pkg/profile"
"github.com/wtfutil/wtf/app"
"github.com/wtfutil/wtf/cfg"
"github.com/wtfutil/wtf/flags"
"github.com/wtfutil/wtf/utils"
"github.com/wtfutil/wtf/wtf"
)
var (
date = "dev"
version = "dev"
)
/* -------------------- Main -------------------- */
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
// Parse and handle flags
flags := flags.NewFlags()
flags.Parse()
// Load the configuration file
cfg.Initialize(flags.HasCustomConfig())
config := cfg.LoadWtfConfigFile(flags.ConfigFilePath())
wtf.SetTerminal(config)
flags.RenderIf(version, date, config)
if flags.Profile {
defer profile.Start(profile.MemProfile).Stop()
}
openFileUtil := config.UString("wtf.openFileUtil", "open")
openURLUtil := utils.ToStrs(config.UList("wtf.openUrlUtil", []interface{}{}))
utils.Init(openFileUtil, openURLUtil)
/* Initialize the App Manager */
appMan := app.NewAppManager()
appMan.MakeNewWtfApp(config, flags.Config)
currentApp, err := appMan.Current()
if err != nil {
fmt.Printf("\n%s %v\n", aurora.Red("ERROR"), err)
os.Exit(1)
}
currentApp.Run()
}