Add a bunch of aliases to align with gh#91
Conversation
Aligns with gh CLI which supports: - gh pr ls / gh issue ls / gh label ls - gh pr new / gh issue new Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Opens the resource in the browser instead of displaying it in the terminal. Aligns with gh CLI behavior. Supported commands: - forge pr view --web - forge pr list --web - forge issue view --web - forge issue list --web - forge label list --web Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When --force is set and the label already exists, update it instead of failing. Aligns with gh CLI behavior. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
andrew
left a comment
There was a problem hiding this comment.
Thanks for this, the gh-compat direction is very welcome. A few things before merging:
Blocking
--web URLs are GitHub-only (internal/cli/pr.go, internal/cli/issue.go)
pr view --web builds https://{domain}/{owner}/{repo}/pull/{N}. That path is wrong for every non-GitHub forge we support: Gitea/Forgejo use /pulls/{N}, GitLab uses /-/merge_requests/{N}, Bitbucket uses /pull-requests/{N}.
The fix is right there though: three lines below, the code already fetches the PR, which has pr.HTMLURL populated by each backend. Move the flagWeb check after the Get() call and open pr.HTMLURL instead. Same for issue view --web with issue.HTMLURL.
pr list --web and label list --web have the same problem but no object to read from. browse.go already hardcodes /pulls so this is at least consistent with an existing bug; happy to accept it for now and push URL construction into the Forge interface in a follow-up.
Should fix
--labels alias registration
Binding a second StringSliceVar to the same &flagLabels has two side effects:
- Both
--labeland--labelsshow in--helpwith identical descriptions --label foo --labels baryields["bar"], not["foo","bar"], because each pflag slice value tracks its ownchangedbit and resets on first Set
Cleaner would be a SetNormalizeFunc that rewrites labels to label, or at minimum cmd.Flags().MarkHidden("labels") after registering it.
Notes (no change needed)
repoFromFlagnow rejects 4+ segments. GitLab subgroups (gitlab.com/group/sub/project) hit this, but the oldLastIndexcode parsed them wrong anyway andghitself only does 3 parts, so not a regression. The explicit error is an improvement.isLabelExistsErrorstring-matching is brittle (a forge with different wording falls through) but there's no typed error to check and the failure mode is just "didn't upsert", so acceptable.--forcewith neither--colornor--descriptionsends an empty update; that's a no-op on most forges and matchesgh label create --force.--forge-typeis silently ignored when--repoincludes a host segment. Probably correct (explicit host wins), just flagging.
The repoFromFlag tests look good and stay hermetic since codeberg.org is in the pre-registered map.
Thanks. Addressed the rest too. |
Fixed. I eyeballed the status codes for bitbucket/gitlab tbh and didn't test them, but tbf I didn't test the error message pattern matching on those forges either. |
|
No problem, I appreciate the eyeballs! |
--webflag to open in browser--forceflag to upsert labelsThose were all things that I either 1) depend on in my wrapper scripts in my dotfiles 2) extracted from failed tool calls in my claude history.
Let me know if you want me to split that up, but I think the changes are simple enough and splitting them up, then merging them back together causes merge conflicts.