Skip to content

Read gh api shorthand clusters the way gh does - #156

Merged
arnelirobles merged 2 commits into
mainfrom
fix/gh-api-cluster
Oct 29, 2026
Merged

arnelirobles merged 2 commits into
mainfrom
fix/gh-api-cluster

Conversation

@arnelirobles

@arnelirobles arnelirobles commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

gh api -iXDELETE repos/o/r got past the destructive rule from #144: the parser only read -X at the start of a single-dash argument, so a cluster led by -i hid the method. The guard now walks each shorthand cluster the way gh's flag parser does (-i takes no value; -X, -f, -F, -H, -p, -q, -t take the rest of the cluster or the next argument) and refuses a shorthand it does not know. Long flags are read the same way: a value-taking flag such as --jq consumes its value, so -X DELETE --jq -XGET no longer reads as GET, an unknown long flag is refused, and every method given must be GET.

New cases in TestGhBypassesAreRefused: -iXDELETE, -iX DELETE, -iftitle=x an unknown -z cluster, -X DELETE --jq -XGET, -X DELETE -X GET and an unknown --bogus flag are refused; -iXGET, -H -XDELETE (a header value) -q .name, --jq -XDELETE --paginate and --hostname ghe.example --include still run. The flag list matches gh api --help from gh 2.102.0. The test fails on main (want a refusal, got err=<nil> ran=[gh api -iXDELETE repos/o/r]) and passes here.

Gates: gofmt, build, vet, gen-docs, style-scan, golangci-lint, gosec, govulncheck and go test -race ./... pass.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@arnelirobles
arnelirobles marked this pull request as ready for review October 29, 2026 16:30
@arnelirobles
arnelirobles merged commit 54f88fd into main Oct 29, 2026
3 checks passed
@arnelirobles
arnelirobles deleted the fix/gh-api-cluster branch October 29, 2026 16:30
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