Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 25, 2026

CLI commands were using raw fmt.Printf/fmt.Println calls that bypassed the console formatting system, causing inconsistent styling, messages routed to stdout instead of stderr, and no TTY detection for ANSI codes.

Changes

Converted 95 message formatting calls across 10 CLI files:

  • run_workflow_execution.go (26), remove_command.go (23), status_command.go (15), trial_command.go (7)
  • mcp_secrets.go (6), copilot-agents.go (5), tool_graph.go (4)
  • mcp_list_tools.go (3), mcp_inspect.go (3), mcp_add.go (3)

Pattern applied:

// Before: Raw output to stdout
fmt.Printf("Running workflow: %s\n", name)
fmt.Printf("Warning: %v\n", err)

// After: Console formatted to stderr
fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Running workflow: %s", name)))
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(err.Error()))

Intentionally unchanged: Data output (JSON, tables, Mermaid graphs) remains on stdout for proper piping: gh aw list --json | jq

Impact

  • Consistent color-coded output with visual hierarchy (errors red, warnings orange, success green)
  • Proper stderr routing enables clean piping without message interference
  • TTY-aware output prevents ANSI codes in pipes and CI environments
Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Standardize Console Formatting Across 24 CLI Files</issue_title>
<issue_description>## 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

...


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits January 25, 2026 15:04
…ormatting

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ole formatting

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Standardize console formatting across 24 CLI files Standardize CLI output with console formatting and stderr routing Jan 25, 2026
Copilot AI requested a review from pelikhan January 25, 2026 15:18
@pelikhan pelikhan marked this pull request as ready for review January 25, 2026 17:38
@pelikhan pelikhan merged commit 07f1fc3 into main Jan 25, 2026
118 checks passed
@pelikhan pelikhan deleted the copilot/standardize-console-formatting branch January 25, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Quality] Standardize Console Formatting Across 24 CLI Files

2 participants