2020-06-18 23:54:48 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-06-24 03:23:28 +03:00
|
|
|
"fmt"
|
2020-06-18 23:54:48 +03:00
|
|
|
"os"
|
|
|
|
|
2020-11-24 05:09:48 +03:00
|
|
|
"github.com/makeworld-the-better-one/amfora/client"
|
2020-06-18 23:54:48 +03:00
|
|
|
"github.com/makeworld-the-better-one/amfora/config"
|
|
|
|
"github.com/makeworld-the-better-one/amfora/display"
|
2020-11-28 01:01:29 +03:00
|
|
|
"github.com/makeworld-the-better-one/amfora/subscriptions"
|
2020-06-18 23:54:48 +03:00
|
|
|
)
|
|
|
|
|
2020-09-02 02:55:06 +03:00
|
|
|
var (
|
2020-12-21 20:42:43 +03:00
|
|
|
version = "v1.7.1"
|
2020-09-02 02:55:06 +03:00
|
|
|
commit = "unknown"
|
|
|
|
builtBy = "unknown"
|
|
|
|
)
|
2020-06-24 03:23:28 +03:00
|
|
|
|
2020-06-18 23:54:48 +03:00
|
|
|
func main() {
|
2020-12-07 05:02:41 +03:00
|
|
|
// err := logger.Init()
|
|
|
|
// if err != nil {
|
|
|
|
// panic(err)
|
|
|
|
// }
|
2020-06-18 23:54:48 +03:00
|
|
|
|
2020-06-24 03:23:28 +03:00
|
|
|
if len(os.Args) > 1 {
|
|
|
|
if os.Args[1] == "--version" || os.Args[1] == "-v" {
|
2020-09-02 02:55:06 +03:00
|
|
|
fmt.Println("Amfora", version)
|
|
|
|
fmt.Println("Commit:", commit)
|
|
|
|
fmt.Println("Built by:", builtBy)
|
2020-06-24 03:23:28 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if os.Args[1] == "--help" || os.Args[1] == "-h" {
|
2020-07-10 02:28:39 +03: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")
|
2020-06-24 03:23:28 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-07 05:02:41 +03:00
|
|
|
err := config.Init()
|
2020-06-18 23:54:48 +03:00
|
|
|
if err != nil {
|
2020-08-11 01:50:40 +03:00
|
|
|
fmt.Fprintf(os.Stderr, "Config error: %v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2020-11-28 01:01:29 +03:00
|
|
|
err = subscriptions.Init()
|
2020-08-11 01:50:40 +03:00
|
|
|
if err != nil {
|
2020-11-28 01:01:29 +03:00
|
|
|
fmt.Fprintf(os.Stderr, "subscriptions.json error: %v\n", err)
|
2020-07-10 02:28:39 +03:00
|
|
|
os.Exit(1)
|
2020-06-18 23:54:48 +03:00
|
|
|
}
|
|
|
|
|
2020-11-24 05:09:48 +03:00
|
|
|
client.Init()
|
|
|
|
|
2020-12-21 00:39:33 +03:00
|
|
|
display.Init(version, commit, builtBy)
|
2020-06-24 20:18:23 +03:00
|
|
|
display.NewTab()
|
2020-07-03 19:22:44 +03:00
|
|
|
display.NewTab() // Open extra tab and close it to fully initialize the app and wrapping
|
|
|
|
display.CloseTab()
|
2020-06-24 20:18:23 +03:00
|
|
|
if len(os.Args[1:]) > 0 {
|
2020-06-22 02:48:58 +03:00
|
|
|
display.URL(os.Args[1])
|
2020-06-18 23:54:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if err = display.App.Run(); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|