summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Czapliński <czapkofan@gmail.com>2018-10-31 23:12:00 +0100
committerMateusz Czapliński <czapkofan@gmail.com>2018-10-31 23:20:14 +0100
commit4a6b466943e6b5dfbb2b868197e64e2ab0e4152f (patch)
tree802287397ba7b6f71074bfbaa97edb74a5878531
parentb4fd9248bb453c7a1c7772b0f84c42fb2d447d99 (diff)
print detailed error message for ErrTermNotFound
Closes #15. Unfortunately, it seems that the "terminfo" infrastructure in the Linux/Unix world is defined only at C ABI level (not at file format level), and as such is fundamentally incompatible with pure-Go applications. I don't see a good way to solve this problem in a cross-platform (or, mainly, cross-Unix) way, so I'm currently falling back to displaying an error message, asking user to patch the mess locally for themselves by hand.
-rw-r--r--up.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/up.go b/up.go
index 97b379e..f647e1f 100644
--- a/up.go
+++ b/up.go
@@ -21,6 +21,7 @@ import (
"bufio"
"bytes"
"context"
+ "crypto/sha1"
"fmt"
"io"
"io/ioutil"
@@ -30,6 +31,7 @@ import (
"sync"
"github.com/gdamore/tcell"
+ "github.com/gdamore/tcell/terminfo"
"github.com/mattn/go-isatty"
"github.com/spf13/pflag"
)
@@ -233,6 +235,29 @@ func initTUI() tcell.Screen {
// Init TUI code
// TODO: maybe try gocui or termbox?
tui, err := tcell.NewScreen()
+ if err == terminfo.ErrTermNotFound {
+ term := os.Getenv("TERM")
+ hash := sha1.Sum([]byte(term))
+ // TODO: add a flag which would attempt to perform the download automatically if explicitly requested by user
+ die(fmt.Sprintf(`%[1]s
+Your terminal code:
+ TERM=%[2]s
+was not found in the database provided by tcell library. Please try checking if
+a supplemental database is found for your terminal at one of the following URLs:
+ https://github.com/gdamore/tcell/raw/master/terminfo/database/%.1[3]x/%.4[3]x
+ https://github.com/gdamore/tcell/raw/master/terminfo/database/%.1[3]x/%.4[3]x.gz
+If yes, download it and save in the following directory:
+ $HOME/.tcelldb/%.1[3]x/
+then try running "up" again. If that does not work for you, please first consult:
+ https://github.com/akavel/up/issues/15
+and if you don't see your terminal code mentioned there, please try asking on:
+ https://github.com/gdamore/tcell/issues
+Or, you might try changing TERM temporarily to some other value, for example by
+running "up" with:
+ TERM=xterm up
+Good luck!`,
+ err, term, hash))
+ }
if err != nil {
die(err.Error())
}