~adnano/astronaut

c36219a9b9b35bf21e79f096a98ca687f9a72991 — Adnan Maolood 1 year, 10 months ago 76965cd
Support opening a URL from command line argument
2 files changed, 18 insertions(+), 4 deletions(-)

M doc/astronaut.1.scd
M main.go
M doc/astronaut.1.scd => doc/astronaut.1.scd +1 -1
@@ 6,7 6,7 @@ astronaut - a Gemini browser for the terminal

# SYNOPSIS

_astronaut_ [-v]
_astronaut_ [-v] [URL]

# OPTIONS


M main.go => main.go +17 -3
@@ 23,19 23,28 @@ var (
)

func main() {
	flag := flag.NewFlagSet("", flag.ExitOnError)
	flag.Usage = func() {
		fmt.Printf("usage: %s [-v] [URL]\n", os.Args[0])
	}
	version := flag.Bool("v", false, "print version")
	flag.Parse()
	flag.Parse(os.Args[1:])
	if flag.NArg() > 2 {
		flag.Usage()
		return
	}
	if *version {
		fmt.Println("astronaut", Version)
		return
	}

	if err := run(); err != nil {
	url := flag.Arg(0)
	if err := run(url); err != nil {
		log.Fatal(err)
	}
}

func run() error {
func run(url string) error {
	os.MkdirAll(filepath.Join(xdg.DataHome(), "astronaut"), 0700)
	configHome := filepath.Join(xdg.ConfigHome(), "astronaut")



@@ 64,6 73,11 @@ func run() error {
	defer ui.Close()

	browser := NewBrowser(ui, config)

	if url != "" {
		browser.Command("open", url)
	}

	ui.Init(browser)

	for !ui.Exiting() {