Spinner keeps erasing my line
cflewis opened this issue · 3 comments
Hi there,
I am having a problem using the spinner correctly :(
Here is my code:
func printStatus(s string) func() {
spin := spinner.New(spinner.CharSets[14], 1*time.Second)
spin.Color("fgBlack")
spin.Prefix = s
spin.Start()
time.Sleep(4 * time.Second)
return func() {
spin.Stop()
fmt.Printf("\n")
}
}
When the spinner is executing, it starts backspacing my lines:
e.g.
Creating cust
Creating credentia⠙
(from "Creating customer" and "Creating credentials")
Every spin iteration moves back one more. In Bash this appears to work correctly.
I could get over this by using Prefix
, but when the spinner ends it deletes the whole line, which isn't what I want. I want the output to remain.
What can I do here?
Thank you!
I got around the eating, so I'm going to close. Here's what I did:
func printStatus(s string) func() {
spin := spinner.New(spinner.CharSets[26], 1*time.Second)
spin.Prefix = s
spin.Start()
time.Sleep(4 * time.Second)
return func() {
spin.Stop()
fmt.Println(s + "... done")
}
}
This is interesting. Thank you very much for the follow up. Do you know if this is Fish specific or fish and zsh specific?
I misspoke (misstyped?) it wasn't limited to any shell, it was every shell, including Bash.
I am sure I Am Holding It Wrong but I am not sure exactly how. I am happy with what I think is a workaround, but maybe it's not a workaround and how it should be done?