Skip to content

Add a spinner during atmos validate stacks operations #1003

@RoseSecurity

Description

@RoseSecurity

Describe the Feature

How does the team feel about adding a spinner to the atmos validate stacks operation? It can be difficult to tell whether the command is hanging or actively running in the background. Here’s the current output:

. [infra] (HOST) workspace ⨠ atmos validate stacks

Then:

. [infra] (HOST) workspace ⨠ atmos validate stacks
all stacks validated successfully

Expected Behavior

  • Adds a spinner to the validation operation:
. [infra] (HOST) workspace ⨠ atmos validate stacks
⣯ Validating Atmos stacks...

Use Case

  • It can be difficult to tell whether the command is hanging or actively running in the background

Describe Ideal Solution

  • Add spinner to the operation:
	// Initialize spinner
	s := spinner.New()
	s.Style = theme.Styles.Link

	var opts []tea.ProgramOption
	if !CheckTTYSupport() {
		// set tea.WithInput(nil) workaround tea program not run on not TTY mod issue
		opts = []tea.ProgramOption{tea.WithoutRenderer(), tea.WithInput(nil)}
		u.LogTrace("No TTY detected. Falling back to basic output. This can happen when no terminal is attached or when commands are pipelined.")
		fmt.Println(message)
	}

	p := tea.NewProgram(modelSpinner{
		spinner: s,
		message: message,
	}, opts...)

	spinnerDone := make(chan struct{})
	go func() {
		if _, err := p.Run(); err != nil {
			// If there's any error running the spinner, just print the message
			fmt.Println(message)
			u.LogError(fmt.Errorf("failed to run spinner: %w", err))
		}
		close(spinnerDone)
	}()

Alternatives Considered

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions