more iostreams passing

This commit is contained in:
vilmibm 2020-11-02 11:47:12 -08:00
parent 893fe09a83
commit 47eef416b3
2 changed files with 10 additions and 7 deletions

View file

@ -3,7 +3,6 @@ package view
import (
"errors"
"fmt"
"io"
"net/http"
"sort"
"strings"
@ -112,11 +111,13 @@ func viewRun(opts *ViewOptions) error {
return printHumanPrPreview(opts.IO, pr)
}
cs := opts.IO.ColorScheme()
return printRawPrPreview(opts.IO.Out, cs, pr)
return printRawPrPreview(opts.IO, pr)
}
func printRawPrPreview(out io.Writer, cs *iostreams.ColorScheme, pr *api.PullRequest) error {
func printRawPrPreview(io *iostreams.IOStreams, pr *api.PullRequest) error {
out := io.Out
cs := io.ColorScheme()
reviewers := prReviewerList(*pr, cs)
assignees := prAssigneeList(*pr)
labels := prLabelList(*pr)

View file

@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"fmt"
"io"
"math/rand"
"net/http"
"os"
@ -214,7 +213,7 @@ func gardenRun(opts *GardenOptions) error {
geo.Width = 0
}
clear(opts.IO)
drawGarden(cs, out, garden, player)
drawGarden(opts.IO, garden, player)
// thanks stackoverflow https://stackoverflow.com/a/17278776
_ = exec.Command("stty", sttyFileArg, "/dev/tty", "cbreak", "min", "1").Run()
@ -424,7 +423,10 @@ func plantGarden(commits []*Commit, geo *Geometry) [][]*Cell {
return garden
}
func drawGarden(cs *iostreams.ColorScheme, out io.Writer, garden [][]*Cell, player *Player) {
func drawGarden(io *iostreams.IOStreams, garden [][]*Cell, player *Player) {
out := io.Out
cs := io.ColorScheme()
fmt.Fprint(out, "\033[?25l") // hide cursor. it needs to be restored at command exit.
sl := ""
for y, gardenRow := range garden {