mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Move SetTerminal out of main and into its own file
Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
parent
cf6d2fc061
commit
8b00760267
@ -84,14 +84,14 @@ func readGitHubAPIKey(cfg *config.Config) string {
|
|||||||
|
|
||||||
func (wtfApp *WtfApp) contributorThankYouMessage() string {
|
func (wtfApp *WtfApp) contributorThankYouMessage() string {
|
||||||
str := " On behalf of all the users of WTF, thank you for contributing to the source code."
|
str := " On behalf of all the users of WTF, thank you for contributing to the source code."
|
||||||
str += fmt.Sprintf(" %s", aurora.Green("You rock."))
|
str += fmt.Sprintf(" %s", aurora.Green("\n\n You rock."))
|
||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wtfApp *WtfApp) sponsorThankYouMessage() string {
|
func (wtfApp *WtfApp) sponsorThankYouMessage() string {
|
||||||
str := " Your sponsorship of WTF makes a difference. Thank you for sponsoring and supporting WTF."
|
str := " Your sponsorship of WTF makes a difference. Thank you for sponsoring and supporting WTF."
|
||||||
str += fmt.Sprintf(" %s", aurora.Green("You're awesome."))
|
str += fmt.Sprintf(" %s", aurora.Green("\n\n You're awesome."))
|
||||||
|
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
29
main.go
29
main.go
@ -12,44 +12,20 @@ import (
|
|||||||
_ "time/tzdata"
|
_ "time/tzdata"
|
||||||
|
|
||||||
"github.com/logrusorgru/aurora"
|
"github.com/logrusorgru/aurora"
|
||||||
"github.com/olebedev/config"
|
|
||||||
"github.com/pkg/profile"
|
"github.com/pkg/profile"
|
||||||
|
|
||||||
"github.com/rivo/tview"
|
|
||||||
"github.com/wtfutil/wtf/app"
|
"github.com/wtfutil/wtf/app"
|
||||||
"github.com/wtfutil/wtf/cfg"
|
"github.com/wtfutil/wtf/cfg"
|
||||||
"github.com/wtfutil/wtf/flags"
|
"github.com/wtfutil/wtf/flags"
|
||||||
"github.com/wtfutil/wtf/utils"
|
"github.com/wtfutil/wtf/utils"
|
||||||
|
"github.com/wtfutil/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tviewApp *tview.Application
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
date = "dev"
|
date = "dev"
|
||||||
version = "dev"
|
version = "dev"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* -------------------- Functions -------------------- */
|
|
||||||
|
|
||||||
func setTerm(config *config.Config) {
|
|
||||||
term := config.UString("wtf.term", os.Getenv("TERM"))
|
|
||||||
err := os.Setenv("TERM", term)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("\n%s Failed to set $TERM to %s.\n", aurora.Red("ERROR"), aurora.Yellow(term))
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// // FIXME: Move this into the AppManager
|
|
||||||
// panic("BOO")
|
|
||||||
// func makeWtfApp(config *config.Config, flagConfig string) app.WtfApp {
|
|
||||||
// tviewApp = tview.NewApplication()
|
|
||||||
// wtfApp := app.NewWtfApp(tviewApp, config, flagConfig)
|
|
||||||
// wtfApp.Start()
|
|
||||||
|
|
||||||
// return wtfApp
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* -------------------- Main -------------------- */
|
/* -------------------- Main -------------------- */
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -62,7 +38,8 @@ func main() {
|
|||||||
// Load the configuration file
|
// Load the configuration file
|
||||||
cfg.Initialize(flags.HasCustomConfig())
|
cfg.Initialize(flags.HasCustomConfig())
|
||||||
config := cfg.LoadWtfConfigFile(flags.ConfigFilePath())
|
config := cfg.LoadWtfConfigFile(flags.ConfigFilePath())
|
||||||
setTerm(config)
|
|
||||||
|
wtf.SetTerminal(config)
|
||||||
|
|
||||||
flags.RenderIf(version, date, config)
|
flags.RenderIf(version, date, config)
|
||||||
|
|
||||||
|
22
wtf/terminal.go
Normal file
22
wtf/terminal.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package wtf
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/logrusorgru/aurora"
|
||||||
|
"github.com/olebedev/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SetTerminal sets the TERM environment variable, defaulting to whatever the OS
|
||||||
|
// has as the current value if none is specified.
|
||||||
|
// See https://www.gnu.org/software/gettext/manual/html_node/The-TERM-variable.html for
|
||||||
|
// more details.
|
||||||
|
func SetTerminal(config *config.Config) {
|
||||||
|
term := config.UString("wtf.term", os.Getenv("TERM"))
|
||||||
|
err := os.Setenv("TERM", term)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("\n%s Failed to set $TERM to %s.\n", aurora.Red("ERROR"), aurora.Yellow(term))
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user