Objective
Migrate core workflow operation commands from Run to RunE for idiomatic error handling.
Context
This is Batch 2 of 5 in the Run→RunE migration. These are the most frequently used commands for workflow management.
Parent Issue: #5300
Depends on: Batch 1 (error formatter setup) must be completed first
Commands to Migrate
- run - Execute workflows
- status - Check workflow status
- logs - Download and view workflow logs
- audit - Investigate workflow failures
Approach
For each command file:
- Change
Run: to RunE:
- Remove
os.Exit(1) calls
- Return errors directly instead of handling them inline
- Keep
console.FormatErrorMessage for now (handled by root command)
Pattern Example
Before:
Run: func(cmd *cobra.Command, args []string) {
if err := cli.RunWorkflow(...); err != nil {
fmt.Fprintln(os.Stderr, console.FormatErrorMessage(err.Error()))
os.Exit(1)
}
}
After:
RunE: func(cmd *cobra.Command, args []string) error {
return cli.RunWorkflow(...)
}
Files to Modify
pkg/cli/run_command.go
pkg/cli/status_command.go
pkg/cli/logs.go
pkg/cli/audit_command.go
Acceptance Criteria
Testing
# Build and test each command
make build
# Test run command
./gh-aw run --help
./gh-aw run nonexistent-workflow # Should error gracefully
# Test status command
./gh-aw status --help
./gh-aw status
# Test logs command
./gh-aw logs --help
./gh-aw logs
# Test audit command
./gh-aw audit --help
./gh-aw audit 12345
# Run test suite
make test-unit
Related to #5300
AI generated by Plan Command for #5282
Objective
Migrate core workflow operation commands from
RuntoRunEfor idiomatic error handling.Context
This is Batch 2 of 5 in the Run→RunE migration. These are the most frequently used commands for workflow management.
Parent Issue: #5300
Depends on: Batch 1 (error formatter setup) must be completed first
Commands to Migrate
Approach
For each command file:
Run:toRunE:os.Exit(1)callsconsole.FormatErrorMessagefor now (handled by root command)Pattern Example
Before:
After:
Files to Modify
pkg/cli/run_command.gopkg/cli/status_command.gopkg/cli/logs.gopkg/cli/audit_command.goAcceptance Criteria
RunEinstead ofRunos.Exit(1)calls in any of these commandsTesting
Related to #5300