Skip to content

H13 [MED/CLI] --body / --body-file mutex across all body-bearing commands (H16)#33

Merged
mfwolffe merged 8 commits into
trunkfrom
h13/body-flag-mutex
May 23, 2026
Merged

H13 [MED/CLI] --body / --body-file mutex across all body-bearing commands (H16)#33
mfwolffe merged 8 commits into
trunkfrom
h13/body-flag-mutex

Conversation

@espadonne
Copy link
Copy Markdown
Contributor

Summary

Closes H16 — and audits the rest of the body-bearing surface for the same shape. Pre-fix passing both --body "X" and --body-file path silently used the file and discarded the inline content; users had no signal their typo was a no-op. gh-compat refuses the combination at parse.

Applied cmd.MarkFlagsMutuallyExclusive("body", "body-file") at every site that exposes both flags:

  • pr edit, issue edit
  • pr create, issue create
  • pr comment, issue comment
  • pr review
  • pr merge

Error message comes from cobra: if any flags in the group [body body-file] are set none of the others can be; [body body-file] were all set. Stable and self-explanatory.

The internal readBodyFile(path, fallback, ...) helpers still pick file over inline when both fields are populated programmatically (existing tests like TestCreateBodyFileWins cover that path). The mutex sits in front at the cobra layer — direct Run(opts) callers (tests, library users) keep the precedence behavior; CLI users get the error.

Test plan

  • TestEditRejectsBodyPlusBodyFile (pr/edit) — cobra-level mutex fires
  • Existing precedence tests (TestCreateBodyFileWins etc.) still pass — they call Run(opts) directly, bypassing cobra
  • make ci clean
  • Reviewer: shithub pr edit 1 -R o/r --body x --body-file /tmp/y — expect parse error referencing both flags

@mfwolffe mfwolffe merged commit ae7fd5b into trunk May 23, 2026
3 checks passed
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.

2 participants