Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline stdout with suffix #100

Closed
kavimaluskam opened this issue Jul 4, 2020 · 1 comment
Closed

Multiline stdout with suffix #100

kavimaluskam opened this issue Jul 4, 2020 · 1 comment

Comments

@kavimaluskam
Copy link

I am trying to use spinner and the spinner keep printing stdout line by line instead of refreshing:

Please enter your username: asd
⠋ Loggin into platform as asd...
⠙ Loggin into platform as asd...
⠚ Loggin into platform as asd...
⠒ Loggin into platform as asd...
⠂ Loggin into platform as asd...
⠂ Loggin into platform as asd...
⠒ Loggin into platform as asd...
⠲ Loggin into platform as asd...
⠴ Loggin into platform as asd...
⠦ Loggin into platform as asd...
⠖ Loggin into platform as asd...

Below attached my code, is it a normal behavior?

reader := bufio.NewReader(os.Stdin)

fmt.Printf("Please enter your username: ")
username, _ := reader.ReadString('\n')
username = strings.TrimSuffix(username, "\n")

s := spinner.New(spinner.CharSets[24], 100*time.Millisecond)
s.Suffix = fmt.Sprintf(" Loggin into platform as %s...\n", username)
s.Color("magenta")
s.FinalMSG = fmt.Sprintf("Successfully signed in as %s\n", username)
s.Start()
time.Sleep(2 * time.Second)

s.Stop()
@briandowns
Copy link
Owner

Thanks for filing this. Update your suffix line to not include the new line character and you should be good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants