-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
48 lines (39 loc) · 1013 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"flag"
"fmt"
"log"
"os"
tea "github.com/charmbracelet/bubbletea"
"github.com/dustin-ward/ttype/internal/app"
"github.com/dustin-ward/ttype/internal/config"
"github.com/muesli/termenv"
)
var VERSION string = "v0.4.0"
var zen_flag bool
var version_flag bool
func init() {
flag.BoolVar(&version_flag, "version", false, "print version of the application")
flag.BoolVar(&zen_flag, "zen", false, "enable zen mode (default=false)")
flag.Parse()
}
func main() {
if version_flag {
fmt.Println(VERSION)
os.Exit(0)
}
config := config.Config{
ZenMode: zen_flag,
}
app.Config = config
// Ensure colour terminal is available
colour_profile := termenv.ColorProfile()
if colour_profile > termenv.ANSI {
fmt.Println("WARNING: no colour terminal was detected. This application depends on colour support.\nPress 'enter' to continue...")
fmt.Scanln()
}
p := tea.NewProgram(app.NewAppModel(app.StateDefault, nil))
if _, err := p.Run(); err != nil {
log.Fatal(err)
}
}