We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I tried to use uilive to make multiple parallel spinners work based on this comment on stackoverflow.
The code itself looks like this:
package main import ( "fmt" "github.com/gosuri/uilive" "github.com/theckman/yacspin" "io" "time" ) func main() { writer := uilive.New() writer2 := writer.Newline() writer.Start() defer writer.Stop() spinner1, _ := createSpinner1(writer) spinner2, _ := createSpinner2(writer2) spinner1.Start() time.Sleep(2 * time.Second) // update message spinner1.Message("uploading files") time.Sleep(2 * time.Second) spinner2.Start() time.Sleep(2 * time.Second) spinner1.Message("test") time.Sleep(2 * time.Second) spinner2.Stop() spinner1.Stop() } func createSpinner1(writer io.Writer) (*yacspin.Spinner, error) { // build the configuration, each field is documented cfg := yacspin.Config{ Prefix: "s1", Writer: writer, Frequency: 100 * time.Millisecond, CharSet: yacspin.CharSets[11], Suffix: " ", // puts a least one space between the animating spinner and the Message Message: "collecting files", SuffixAutoColon: true, ColorAll: true, Colors: []string{"fgYellow"}, StopCharacter: "✓", StopColors: []string{"fgGreen"}, StopMessage: "done", StopFailCharacter: "✗", StopFailColors: []string{"fgRed"}, StopFailMessage: "failed", } s, err := yacspin.New(cfg) if err != nil { return nil, fmt.Errorf("failed to make spinner from struct: %w", err) } return s, nil } func createSpinner2(writer io.Writer) (*yacspin.Spinner, error) { // build the configuration, each field is documented cfg := yacspin.Config{ Writer: writer, Prefix: "s2", Frequency: 100 * time.Millisecond, CharSet: yacspin.CharSets[11], Suffix: " ", // puts a least one space between the animating spinner and the Message Message: "doing stuff", SuffixAutoColon: true, ColorAll: true, Colors: []string{"fgYellow"}, StopCharacter: "✓", StopColors: []string{"fgGreen"}, StopMessage: "done", StopFailCharacter: "✗", StopFailColors: []string{"fgRed"}, StopFailMessage: "failed", } s, err := yacspin.New(cfg) if err != nil { return nil, fmt.Errorf("failed to make spinner from struct: %w", err) } return s, nil }
I have absolutely no idea why this does not work as it should write to two different writers as in spinner.go in line 830 defined:
spinner.go
if s.buffer.Len() > 0 { if _, err := s.writer.Write(s.buffer.Bytes()); err != nil { panic(fmt.Sprintf("failed to output buffer to writer: %v", err)) } }
Could you please offer some assistance?
Thanks in advance.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I tried to use uilive to make multiple parallel spinners work based on this comment on stackoverflow.
The code itself looks like this:
I have absolutely no idea why this does not work as it should write to two different writers as in
spinner.go
in line 830 defined:Could you please offer some assistance?
Thanks in advance.
The text was updated successfully, but these errors were encountered: