Refactoring to reduce package count

* Consolidate util and utils into the same package
* Move internal/onboard into internal/cli/onboard
* Move maybeOnboard into the onboard package
This commit is contained in:
Arturo Filastò 2019-12-02 15:15:50 +02:00
commit 58199a020e
12 changed files with 189 additions and 194 deletions

View file

@ -11,7 +11,7 @@ import (
"github.com/apex/log"
"github.com/fatih/color"
colorable "github.com/mattn/go-colorable"
"github.com/ooni/probe-cli/internal/util"
"github.com/ooni/probe-cli/utils"
)
// Default handler outputting to stderr.
@ -67,7 +67,7 @@ func logSectionTitle(w io.Writer, f log.Fields) error {
title := f.Get("title").(string)
fmt.Fprintf(w, "┏"+strings.Repeat("━", colWidth+2)+"┓\n")
fmt.Fprintf(w, "┃ %s ┃\n", util.RightPad(title, colWidth))
fmt.Fprintf(w, "┃ %s ┃\n", utils.RightPad(title, colWidth))
fmt.Fprintf(w, "┗"+strings.Repeat("━", colWidth+2)+"┛\n")
return nil
}
@ -84,7 +84,7 @@ func logTable(w io.Writer, f log.Fields) error {
continue
}
line := fmt.Sprintf("%s: %s", color.Sprint(name), f.Get(name))
lineLength := util.EscapeAwareRuneCountInString(line)
lineLength := utils.EscapeAwareRuneCountInString(line)
lines = append(lines, line)
if colWidth < lineLength {
colWidth = lineLength
@ -94,7 +94,7 @@ func logTable(w io.Writer, f log.Fields) error {
fmt.Fprintf(w, "┏"+strings.Repeat("━", colWidth+2)+"┓\n")
for _, line := range lines {
fmt.Fprintf(w, "┃ %s ┃\n",
util.RightPad(line, colWidth),
utils.RightPad(line, colWidth),
)
}
fmt.Fprintf(w, "┗"+strings.Repeat("━", colWidth+2)+"┛\n")