Skip to content

[plan] Configure spinner to write to stderr for better output redirection #5103

@github-actions

Description

@github-actions

Objective

Configure spinners to write to os.Stderr instead of os.Stdout to follow CLI best practices and enable better output redirection.

Context

CLI tools should write:

  • Progress indicators (spinners, status) → stderr
  • Actual command output (data, results) → stdout

This allows users to redirect actual output while still seeing progress in the terminal.

Current Behavior

gh-aw logs download > output.txt
# Spinner output and actual output both mixed in file

Desired Behavior

gh-aw logs download > output.txt
# Spinner shows in terminal, only data goes to file

Approach

Update spinner initialization in pkg/console/spinner.go to use the WithWriter() option:

func NewSpinner(message string) *SpinnerWrapper {
    // ... TTY detection ...
    
    s := spinner.New(
        spinner.CharSets[14],
        100*time.Millisecond,
        spinner.WithWriter(os.Stderr), // Add this option
    )
    
    // ... rest of setup ...
}

Benefits

  • Better piping: Users can redirect output without spinner interference
  • Best practice alignment: Follows recommended CLI tool design
  • Cleaner output: Progress indicators stay in terminal, data goes where directed

Files to Modify

  • pkg/console/spinner.go - Add spinner.WithWriter(os.Stderr) to initialization

Acceptance Criteria

  • Spinner configured to write to stderr
  • Spinner still displays correctly in terminal
  • Output redirection works correctly (spinner in terminal, data to file)
  • TTY detection behavior unchanged
  • Existing tests pass

Testing

Manual test:

# Spinner should appear in terminal, only logs in file
gh-aw logs download > output.txt

# Check that output.txt contains only actual output
cat output.txt

References

AI generated by Plan Command for discussion #5094

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions