-
-
Notifications
You must be signed in to change notification settings - Fork 214
Unwanted newline with spinnerΒ #731
Copy link
Copy link
Closed
Description
How can I get the spinner to not print a new line before the text?
output during spinner:
π Creating Devspace Instance
β’ Instance name: rwatkins-3
β’ Size: M
β’ Location: US_EAST1
β’ Image: devspace-base
β Waiting for instance to start (3s)
output after spinner complete. RemoveWhenDone is set:
π Creating Devspace Instance
β’ Instance name: rwatkins-3
β’ Size: M
β’ Location: US_EAST1
β’ Image: devspace-base
β’ Instance status: β
Running
Spinner functions:
// StartSpinner starts a spinning animation with a message
func (ui *PtermUI) StartSpinner(message string) {
ui.mu.Lock()
defer ui.mu.Unlock()
// Use a regular PTerm spinner for single operations
if _, exists := ui.spinners[message]; !exists {
// indentedMessage := ui.getIndent() + message
spinner, _ := pterm.DefaultSpinner.Start()
spinner.UpdateText(message)
ui.spinners[message] = spinner
}
}
// StopSpinner stops the spinning animation
func (ui *PtermUI) StopSpinner() {
ui.mu.Lock()
defer ui.mu.Unlock()
// Stop all regular spinners
for _, spinner := range ui.spinners {
spinner.Stop()
}
ui.spinners = make(map[string]*pterm.SpinnerPrinter)
}
// SpinnerSuccess resolves a spinner with success
func (ui *PtermUI) SpinnerSuccess(message string) {
ui.mu.Lock()
defer ui.mu.Unlock()
if spinner, exists := ui.spinners[message]; exists {
// Use the original message for the success output (without indentation)
spinner.Success(message)
delete(ui.spinners, message)
}
}
// SpinnerWarning resolves a spinner with warning
func (ui *PtermUI) SpinnerWarning(message string) {
ui.mu.Lock()
defer ui.mu.Unlock()
if spinner, exists := ui.spinners[message]; exists {
// Use the original message for the warning output (without indentation)
spinner.Warning(message)
delete(ui.spinners, message)
}
}
// SpinnerFail resolves a spinner with failure
func (ui *PtermUI) SpinnerFail(message string) {
ui.mu.Lock()
defer ui.mu.Unlock()
if spinner, exists := ui.spinners[message]; exists {
// Use the original message for the fail output (without indentation)
spinner.Fail(message)
delete(ui.spinners, message)
}
}
Calling code:
u.StartSpinner("Waiting for instance to start")
...
u.SpinnerSuccess("Waiting for instance to start")
u.PrintItem("Instance status", "β
Running")
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels