Skip to content

Commit

Permalink
gc fix error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
geremachek committed Sep 16, 2021
1 parent 5cfa967 commit 69f7241
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ func main() {
pflag.IntVarP(&height, "height", "H", 10, "set how many elements are displayed at once")
pflag.Parse()

message := "basil: can't start interface\n%s\n"

// start the ui, trapping errors

if u, e := ui.NewUi(height); e == nil {
if err := u.Start(); err != nil {
fmt.Fprintf(os.Stderr, message, e)
printErr(e)
}
} else {
fmt.Fprintf(os.Stderr, message, e)
printErr(e)
}
}

func printErr(e error) {
fmt.Fprintf(os.Stderr, "basil: can't start interface\n%s\n", e)
os.Exit(1)
}
2 changes: 1 addition & 1 deletion ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (u ui) drawAngleMode() {

func (u *ui) matchKeys(input *tcell.EventKey) {
switch input.Key() {
case tcell.KeyCtrlLeftSq: u.running = false
case tcell.KeyESC: u.running = false
case tcell.KeyEnter: u.parseLine()
case tcell.KeyDEL, tcell.KeyBackspace: u.buff.delete(u.scr)
case tcell.KeyRune: u.buff.push(u.scr, input.Rune())
Expand Down

0 comments on commit 69f7241

Please sign in to comment.