Merge pull request #688 from cli/spinner-writer

Enable tests to capture spinner output
This commit is contained in:
Nate Smith 2020-03-24 14:31:11 -05:00 committed by GitHub
commit 39839c96da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -295,7 +295,7 @@ func repoFork(cmd *cobra.Command, args []string) error {
greenCheck := utils.Green("✓")
out := colorableOut(cmd)
s := utils.Spinner()
s := utils.Spinner(out)
loading := utils.Gray("Forking ") + utils.Bold(utils.Gray(ghrepo.FullName(toFork))) + utils.Gray("...")
s.Suffix = " " + loading
s.FinalMSG = utils.Gray(fmt.Sprintf("- %s\n", loading))

View file

@ -2,6 +2,7 @@ package utils
import (
"fmt"
"io"
"strings"
"time"
@ -68,6 +69,8 @@ func Humanize(s string) string {
return strings.Map(h, s)
}
func Spinner() *spinner.Spinner {
return spinner.New(spinner.CharSets[11], 400*time.Millisecond)
func Spinner(w io.Writer) *spinner.Spinner {
s := spinner.New(spinner.CharSets[11], 400*time.Millisecond)
s.Writer = w
return s
}