Skip to content

[Code Quality] Standardize Console Formatting Across 24 CLI Files #11767

@github-actions

Description

@github-actions

Description

24 CLI files currently use raw fmt.Printf/fmt.Println calls that bypass the console formatting system, creating inconsistent user experience. These files should use console.Format* functions for consistent styling, color support, and TTY-aware output.

Current Problem

Anti-Pattern (used in 24 files):

// ❌ BAD - Raw fmt.Printf without console formatting
fmt.Printf("Running workflow: %s\n", name)
fmt.Printf("Warning: Could not check status: %v\n", err)
fmt.Println("Success!")

Correct Pattern:

// ✅ GOOD - Console formatted with appropriate message types
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Running workflow: %s", name)))
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Could not check status: %v", err)))
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Success!"))

Impact

Current Issues:

  • ❌ Inconsistent visual appearance across commands
  • ❌ No color/styling on important messages
  • ❌ Harder to distinguish message types (info vs warning vs error)
  • ❌ Messages go to stdout instead of stderr (mixes with data output)
  • ❌ No TTY detection (ANSI codes in piped output)

After Fix:

  • ✅ Consistent, color-coded output across all commands
  • ✅ Clear visual hierarchy (errors in red, warnings in orange, success in green)
  • ✅ Proper stderr routing (enables piping: gh aw list --json | jq)
  • ✅ TTY-aware (no ANSI codes in pipes/CI environments)

Files Requiring Updates (Priority Order)

High Priority (Most Instances)

  1. pkg/cli/run_workflow_execution.go - 26 instances
  2. pkg/cli/remove_command.go - 23 instances
  3. pkg/cli/status_command.go - 15 instances
  4. pkg/cli/trial_command.go - 7 instances

Medium Priority (5+ Instances)

  1. pkg/cli/logs_command.go - 6 instances
  2. pkg/cli/list_command.go - 5 instances
  3. pkg/cli/audit_command.go - 5 instances

Lower Priority (<5 Instances Each)

8-24. Other CLI files with 1-4 instances each

Conversion Pattern

Standard Replacements

// 1. Info messages
fmt.Printf("Status: %s\n", status)              // Before
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Status: %s", status))) // After

// 2. Warning messages
fmt.Printf("Warning: %v\n", err)                // Before
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(err.Error())) // After

// 3. Success messages
fmt.Println("Compilation successful!")          // Before
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Compilation successful!")) // After

// 4. Error messages
fmt.Printf("Error: %v\n", err)                  // Before
fmt.Fprintln(os.Stderr, console.FormatErrorMessage(err.Error())) // After

// 5. Commands/paths
fmt.Printf("Run: %s\n", cmd)                    // Before
fmt.Fprintln(os.Stderr, console.FormatCommandMessage(cmd)) // After

Available Console Formatters

  • console.FormatSuccessMessage() - Green checkmark, success messages
  • console.FormatInfoMessage() - Cyan info icon, informational messages
  • console.FormatWarningMessage() - Orange warning icon, warnings
  • console.FormatErrorMessage() - Red X, error messages
  • console.FormatCommandMessage() - Styled commands
  • console.FormatProgressMessage() - Progress indicators
  • console.FormatPromptMessage() - User prompts
  • console.FormatCountMessage() - Counts and metrics
  • console.FormatVerboseMessage() - Verbose/debug output
  • console.FormatLocationMessage() - File paths and locations

Implementation Strategy

Phase 1: High Priority Files (Week 1)

  • Update top 4 files with most instances (71 total replacements)
  • Run make test after each file
  • Verify output manually with ./gh-aw (command)

Phase 2: Medium Priority Files (Week 2)

  • Update files with 5+ instances (16 total replacements)
  • Test in TTY and non-TTY environments

Phase 3: Remaining Files (Week 3)

  • Update remaining 17 files (<5 instances each)
  • Final verification of consistency

Testing Checklist (Per File)

  • All fmt.Print* calls converted to console.Format*
  • Output goes to stderr (not stdout)
  • make test passes
  • make lint passes
  • Manual testing: ./gh-aw (command) looks correct
  • Manual testing: ./gh-aw (command) 2>/dev/null shows no unwanted output to stdout
  • Piping works: ./gh-aw (command) --json | jq (if applicable)

Success Criteria

  • All 24 files updated to use console formatters
  • Zero raw fmt.Print* calls in CLI files (except JSON output to stdout)
  • All messages go to stderr (except structured data output)
  • Consistent visual appearance across all commands
  • All existing tests pass
  • make lint reports no issues
  • Manual testing confirms improved UX

Additional Context

The console formatting system is already well-established in the codebase:

  • ✅ 96 files (20.6%) already use console formatters correctly
  • ✅ Comprehensive pkg/console package with 6,280 lines
  • ✅ Lipgloss integration for adaptive colors (light/dark theme support)
  • ✅ TTY detection for graceful degradation in CI/pipes

This task is about consistency, not building new infrastructure - all tools are already in place.

Source

Extracted from Terminal Stylist Analysis discussion #11742 - Console Output Pattern Review (2026-01-25)

Priority

Medium - Improves user experience and consistency but doesn't block functionality. Large scope (24 files) makes it suitable for incremental improvements.

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 8, 2026, 2:04 PM UTC

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions