Skip to content

Commit

Permalink
more iostreams passing
Browse files Browse the repository at this point in the history
  • Loading branch information
vilmibm committed Nov 2, 2020
1 parent 893fe09 commit 47eef41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions pkg/cmd/pr/view/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package view
import (
"errors"
"fmt"
"io"
"net/http"
"sort"
"strings"
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions pkg/cmd/repo/garden/garden.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"errors"
"fmt"
"io"
"math/rand"
"net/http"
"os"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 47eef41

Please sign in to comment.