| id | FIX-390-PRINT-RENDERED-HELPER |
|---|---|
| title | Extract print_rendered helper from report_cli_parse_error |
| status | complete |
| branch | fix/390-print-rendered-helper |
| worktree | /Users/randlee/Documents/github/sc-compose-worktrees/fix/390-print-rendered-helper |
| target | develop |
FIX-390-FOLLOWUP's QA (PR #393) passed with one new non-blocking finding
(simplification-reviewer): report_cli_parse_error in
crates/sc-compose/src/main.rs now contains the same 5-line
stderr/stdout print pattern twice — once in the early-return
display-request branch (ErrorKind::DisplayHelp | ErrorKind::DisplayVersion)
and once in the fall-through non-JSON usage-error branch:
if error.use_stderr() {
eprint!("{rendered}");
} else {
print!("{rendered}");
}Low severity, no logic-drift risk, but flagged for dispatch per standing policy of routing every QA finding.
Extract a small private helper:
fn print_rendered(rendered: &str, use_stderr: bool) {
if use_stderr {
eprint!("{rendered}");
} else {
print!("{rendered}");
}
}Call it from both branches of report_cli_parse_error, eliminating the
duplication while preserving identical behavior.
crates/sc-compose/src/main.rs: addprint_rendered, call it from both branches ofreport_cli_parse_error.- No behavior change — existing tests in
crates/sc-compose/tests/cli.rsandmain_testscovering--help,--version, and usage-error exit codes/output must continue to pass unmodified. - No new tests required (pure refactor, no new branches or logic).
- No changes to exit code semantics (already finalized by FIX-390 and FIX-390-FOLLOWUP).
- No changes to
CommandErrororexit_codes.
report_cli_parse_errorcontains no duplicated print logic.cargo fmt --all --check,cargo clippy --all-targets --all-features -- -D warnings, andcargo test --workspaceall pass.- Existing CLI parse-error tests pass unmodified.
- PR #393 quality report: #393 (comment)
docs/sprints/fix-390-followup-exit-code-source-of-truth.md
Low — code-quality cleanup, not release-blocking.
- implementation commit:
8a014e9 print_renderedis shared by both display-request and plain-text usage error paths;report_cli_parse_errorcontains no duplicated print block.- existing CLI parse-error tests passed without modification.
- validation PASS:
cargo fmt --all --check,cargo clippy --all-targets --all-features -- -D warnings, andcargo test --workspace.