1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-11-03 02:37:23 -05:00
amfora/amfora.go

72 lines
1.4 KiB
Go
Raw Normal View History

2020-06-18 16:54:48 -04:00
package main
import (
"fmt"
2020-06-18 16:54:48 -04:00
"os"
"github.com/makeworld-the-better-one/amfora/client"
2020-06-18 16:54:48 -04:00
"github.com/makeworld-the-better-one/amfora/config"
"github.com/makeworld-the-better-one/amfora/display"
2020-11-27 17:01:29 -05:00
"github.com/makeworld-the-better-one/amfora/subscriptions"
2020-06-18 16:54:48 -04:00
)
2020-09-01 19:55:06 -04:00
var (
version = "v1.7.2"
2020-09-01 19:55:06 -04:00
commit = "unknown"
builtBy = "unknown"
)
2020-06-18 16:54:48 -04:00
func main() {
2020-12-06 21:02:41 -05:00
// err := logger.Init()
// if err != nil {
// panic(err)
// }
2020-06-18 16:54:48 -04:00
if len(os.Args) > 1 {
if os.Args[1] == "--version" || os.Args[1] == "-v" {
2020-09-01 19:55:06 -04: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 19:28:39 -04: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
}
}
2020-12-06 21:02:41 -05:00
err := config.Init()
2020-06-18 16:54:48 -04:00
if err != nil {
fmt.Fprintf(os.Stderr, "Config error: %v\n", err)
os.Exit(1)
}
2020-11-27 17:01:29 -05:00
err = subscriptions.Init()
if err != nil {
2020-11-27 17:01:29 -05:00
fmt.Fprintf(os.Stderr, "subscriptions.json error: %v\n", err)
2020-07-09 19:28:39 -04:00
os.Exit(1)
2020-06-18 16:54:48 -04:00
}
client.Init()
// Initialize lower-level cview app
if err = display.App.Init(); err != nil {
panic(err)
}
// Initialize Amfora's settings
2020-12-20 16:39:33 -05:00
display.Init(version, commit, builtBy)
display.NewTab()
if len(os.Args[1:]) > 0 {
display.URL(os.Args[1])
2020-06-18 16:54:48 -04:00
}
// Start
2020-06-18 16:54:48 -04:00
if err = display.App.Run(); err != nil {
panic(err)
}
}