1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-06-13 19:10:42 +00:00
amfora/amfora.go

68 lines
1.4 KiB
Go
Raw Normal View History

2020-06-18 20:54:48 +00:00
package main
import (
"fmt"
2020-06-18 20:54:48 +00:00
"os"
"github.com/makeworld-the-better-one/amfora/client"
2020-06-18 20:54:48 +00:00
"github.com/makeworld-the-better-one/amfora/config"
"github.com/makeworld-the-better-one/amfora/display"
"github.com/makeworld-the-better-one/amfora/feeds"
"github.com/makeworld-the-better-one/amfora/logger"
2020-06-18 20:54:48 +00:00
)
2020-09-01 23:55:06 +00:00
var (
2020-11-05 02:31:08 +00:00
version = "v1.6.0"
2020-09-01 23:55:06 +00:00
commit = "unknown"
builtBy = "unknown"
)
2020-06-18 20:54:48 +00:00
func main() {
err := logger.Init()
if err != nil {
panic(err)
}
2020-06-18 20:54:48 +00:00
if len(os.Args) > 1 {
if os.Args[1] == "--version" || os.Args[1] == "-v" {
2020-09-01 23:55:06 +00:00
fmt.Println("Amfora", version)
fmt.Println("Commit:", commit)
fmt.Println("Built by:", builtBy)
return
}
if os.Args[1] == "--help" || os.Args[1] == "-h" {
2020-07-09 23:28:39 +00:00
fmt.Println("Amfora is a fancy terminal browser for the Gemini protocol.")
fmt.Println()
fmt.Println("Usage:")
fmt.Println("amfora [URL]")
fmt.Println("amfora --version, -v")
return
}
}
err = config.Init()
2020-06-18 20:54:48 +00:00
if err != nil {
fmt.Fprintf(os.Stderr, "Config error: %v\n", err)
os.Exit(1)
}
err = feeds.Init()
if err != nil {
2020-08-16 21:42:45 +00:00
fmt.Fprintf(os.Stderr, "feeds.json error: %v\n", err)
2020-07-09 23:28:39 +00:00
os.Exit(1)
2020-06-18 20:54:48 +00:00
}
client.Init()
2020-07-09 23:28:39 +00:00
display.Init()
display.NewTab()
2020-07-03 16:22:44 +00:00
display.NewTab() // Open extra tab and close it to fully initialize the app and wrapping
display.CloseTab()
if len(os.Args[1:]) > 0 {
display.URL(os.Args[1])
2020-06-18 20:54:48 +00:00
}
if err = display.App.Run(); err != nil {
panic(err)
}
}