Skip to content

CommandFailure: a command's error prints as the command words it - #25

Merged
odrobnik merged 1 commit into
mainfrom
feat/command-failure
Oct 18, 2026
Merged

odrobnik merged 1 commit into
mainfrom
feat/command-failure

Conversation

@odrobnik

Copy link
Copy Markdown
Contributor

In-process commands bridged through Shell.parsableCommand(_:) couldn't fail the way the tool they port does. SwiftPorts' git throws its CLIError with git's exact words and status. In an embedding shell (iBash on iOS), the bridge handed that to ArgumentParser's formatter, so this:

$ git fetch foo://example.invalid/x
Error: git: 'remote-foo' is not a git command. See 'git --help'.
fatal: remote helper 'foo' aborted session
[exit 1]

came out where git prints the two lines without Error: and exits 128. Every failing git command in iBash showed Error: error: … and exit 1.

Change

  • New CommandFailure protocol in ShellKit: an Error with a diagnostic (written to stderr as is) and an exitStatus.
  • ParsableCommandBridge catches it before falling back to ArgumentParser's formatter.

Commands that don't conform are unchanged. SwiftPorts' CLIError adopts the protocol in a follow-up PR.

Tests

commandFailurePrintsItsOwnDiagnosticAndStatus checks that the diagnostic is printed byte for byte and the exit status is 128. It fails without the bridge change. All 67 tests pass, and lint is clean.

🤖 Generated with Claude Code

A bridged ArgumentParser command that fails the way a real tool does
(git's `fatal: …`, exit 128) had its text run through ArgumentParser's
formatter: `Error: ` in front, and exit 1. An error conforming to the
new CommandFailure protocol now has its diagnostic written to stderr as
is, and its exit status returned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@odrobnik

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T16:31:01.523421Z 48c4b8a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 48c4b8a07f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@odrobnik
odrobnik merged commit f4f904b into main Oct 18, 2026
6 checks passed
@odrobnik
odrobnik deleted the feat/command-failure branch October 18, 2026 16:34
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.

1 participant