Implement the show command (#53)

This commit is contained in:
Arturo Filastò 2019-10-02 18:23:14 +02:00 committed by Simone Basso
commit f425d3f007
14 changed files with 231 additions and 55 deletions

View file

@ -2,6 +2,7 @@ package util
import (
"bytes"
"bufio"
"fmt"
"os"
"regexp"
@ -112,3 +113,18 @@ func WrapString(s string, lim uint) string {
return buf.String()
}
// ReadLine will read a single line from a bufio.Reader
func ReadLine(r *bufio.Reader) (string, error) {
var (
isPrefix bool
err error
line, ln []byte
)
for isPrefix && err == nil {
line, isPrefix, err = r.ReadLine()
ln = append(ln, line...)
}
return string(ln), err
}