Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion clients/cli/cmd/internal/print/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ func PhraseLogo() {
// Prints the argument if the command is started in non-batch mode
func NonBatchPrintf(msg string, args ...interface{}) {
if !shared.BatchMode {
fmt.Print(fmt.Sprintf(msg, args...))
fmt.Printf(msg, args...)
}
}

func NonBatchPrint(msg string) {
if !shared.BatchMode {
fmt.Print(msg)
}
}

Expand Down
14 changes: 5 additions & 9 deletions clients/cli/cmd/internal/spinner/spinner.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package spinner

import (
"fmt"
"time"

"github.com/phrase/phrase-cli/cmd/internal/shared"
"github.com/phrase/phrase-cli/cmd/internal/print"
)

// While executes f, displays an animated spinner while f runs, and stops when f returns.
Expand Down Expand Up @@ -33,18 +32,15 @@ func Until(c <-chan struct{}) {

// spin animates a spinner until it receives something on the stop channel. It then clears the spinning character and closes the stop channel, signaling that it's done.
func spin(stop chan struct{}) {
if shared.BatchMode {
return
}
chars := []string{`-`, `\`, `|`, `/`}
fmt.Print(" ")
print.NonBatchPrint(" ")
i := 0
for {
fmt.Print("\b")
fmt.Print(chars[i])
print.NonBatchPrint("\b")
print.NonBatchPrint(chars[i])
select {
case <-stop:
fmt.Print("\b ")
print.NonBatchPrint("\b ")
close(stop)
return
case <-time.After(100 * time.Millisecond):
Expand Down
4 changes: 2 additions & 2 deletions clients/cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/phrase/phrase-go/v4 v4.9.0 h1:V+MWmNrxwrYNtmoY41dgrdWT902Er2hcohtQcpVvWmw=
github.com/phrase/phrase-go/v4 v4.9.0/go.mod h1:4XplKvrbHS2LDaXfFp9xrVDtO5xk2WHFm0htutwwd8c=
github.com/phrase/phrase-go/v4 v4.18.0 h1:LSD1izhuwF1TzxlLKdoItfyeSbCuiSs5RCmNiv8vmLg=
github.com/phrase/phrase-go/v4 v4.18.0/go.mod h1:4XplKvrbHS2LDaXfFp9xrVDtO5xk2WHFm0htutwwd8c=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
Loading