Skip to content

D3a [CRIT]: --web mutually exclusive with --json/--jq/--template (C5+C15)#5

Merged
mfwolffe merged 7 commits into
trunkfrom
d3a/output-web-mutex
May 17, 2026
Merged

D3a [CRIT]: --web mutually exclusive with --json/--jq/--template (C5+C15)#5
mfwolffe merged 7 commits into
trunkfrom
d3a/output-web-mutex

Conversation

@espadonne
Copy link
Copy Markdown
Contributor

Summary

C-audit findings C5 + C15: every command that has both --web and the output flags silently picked --web and discarded the machine-readable request. Scripts that pipe --json to jq — common gh-port pattern — got empty stdout and exit 0, no warning.

shithub repo view owner/r --web --json name
# Opening https://shithub.sh/owner/r in your browser.
# exit=0   (--json silently dropped)

shithub issue view 2 -R owner/r --web --json number
# Opening https://shithub.sh/owner/r/issues/2 in your browser.
# exit=0

gh-compat behavior: refuse at parse time with "flag X and Y are mutually exclusive". This PR implements that.

Fix

  1. New helper output.MarkWebMutuallyExclusive(cmd) — three pair-wise cmd.MarkFlagsMutuallyExclusive("web", FlagX) declarations so --json + --jq (existing legal combination) still works.
  2. Applied to 5 commands: issue/view, issue/list, pr/view, pr/list, repo/view.

Cobra emits a strong message on conflict:

Error: if any flags in the group [web json] are set none of the others can be; [json web] were all set

Test plan

  • TestMarkWebMutuallyExclusive — table-driven across all 8 combinations: 4 single-flag cases pass, --json + --jq (legal combo) passes, 3 --web + X cases reject with cobra's mutex message.
  • All affected commands' existing tests still green.
  • make ci green locally.

Notes for follow-up

repo list --web doesn't exist yet (C23). When it's added in a later D3 PR, the same helper applies — single one-line addition.

@mfwolffe mfwolffe merged commit 6f118ac into trunk May 17, 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