Renames a cui function to be more appropriate and adds command line flag for version number

This commit is contained in:
sloumdrone 2019-09-20 09:18:16 -07:00
parent 8c42748432
commit 19f210f243
2 changed files with 19 additions and 7 deletions

View File

@ -65,8 +65,8 @@ func Exit() {
fmt.Print("\n")
fmt.Print("\033[?25h")
HandleAlternateScreen("smam")
HandleAlternateScreen("rmcup")
Tput("smam") // turn off line wrap
Tput("rmcup") // use alternate screen
os.Exit(0)
}
@ -178,7 +178,7 @@ func SetLineMode() {
}
}
func HandleAlternateScreen(opt string) {
func Tput(opt string) {
cmd := exec.Command("tput", opt)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout

20
main.go
View File

@ -7,6 +7,8 @@ package main
// the terms of said license with said license file included.
import (
"flag"
"fmt"
"io/ioutil"
"os"
"strings"
@ -15,6 +17,8 @@ import (
"tildegit.org/sloum/bombadillo/cui"
)
const version = "2.0.0"
var bombadillo *client
var helplocation string = "gopher://colorfield.space:70/1/bombadillo-info"
var settings config.Config
@ -94,8 +98,16 @@ func initClient() error {
}
func main() {
cui.HandleAlternateScreen("rmam")
cui.HandleAlternateScreen("smcup")
getVersion := flag.Bool("v", false, "See version number")
flag.Parse()
if *getVersion {
fmt.Printf("Bombadillo v%s\n", version)
os.Exit(0)
}
args := flag.Args()
cui.Tput("rmam") // turn off line wrapping
cui.Tput("smcup") // use alternate screen
defer cui.Exit()
err := initClient()
if err != nil {
@ -106,11 +118,11 @@ func main() {
// Start polling for terminal size changes
go bombadillo.GetSize()
if len(os.Args) > 1 {
if len(args) > 0 {
// If a url was passed, move it down the line
// Goroutine so keypresses can be made during
// page load
bombadillo.Visit(os.Args[1])
bombadillo.Visit(args[0])
} else {
// Otherwise, load the homeurl
// Goroutine so keypresses can be made during