Add `--json` and `--jq` to `gh pr create`
Issue Details
Author
Describe the feature or problem you’d like to solve
Add a --json response object with the ability to chain a jq query.
Proposed solution
This will avoid doing something like this to get the id or other metadata of a PR we just created:
PR_URL=$(gh pr \ create \ --base main \ --head develop \ --title "Promote dev to main" \ --body "Automated promotion PR from dev to main" \ --fill \ | tail -n1) PR_NUMBER=$(basename "$PR_URL")
And instead make it possible to do this:
PR_NUMBER=$(gh pr \ create \ --base main \ --head develop \ --title "Promote dev to main" \ --body "Automated promotion PR from dev to main" \ --json number,url \ --jq '.[0].number' )
Or this:
PR_NUMBER=$(gh pr \ create \ --base main \ --head develop \ --title "Promote dev to main" \ --body "Automated promotion PR from dev to main" \ --json number,url ) PR_URL=$(echo "$PR_JSON" | jq -r '.[0].url') PR_NUMBER=$(echo "$PR_JSON" | jq -r '.[0].number')
Additional context
Also, this would improve CLI API consistency
Issue Details
Add `--json` and `--jq` to `gh pr create`
Author
Describe the feature or problem you’d like to solve
Add a --json response object with the ability to chain a jq query.
Proposed solution
This will avoid doing something like this to get the id or other metadata of a PR we just created:
PR_URL=$(gh pr \ create \ --base main \ --head develop \ --title "Promote dev to main" \ --body "Automated promotion PR from dev to main" \ --fill \ | tail -n1) PR_NUMBER=$(basename "$PR_URL")
And instead make it possible to do this:
PR_NUMBER=$(gh pr \ create \ --base main \ --head develop \ --title "Promote dev to main" \ --body "Automated promotion PR from dev to main" \ --json number,url \ --jq '.[0].number' )
Or this:
PR_NUMBER=$(gh pr \ create \ --base main \ --head develop \ --title "Promote dev to main" \ --body "Automated promotion PR from dev to main" \ --json number,url ) PR_URL=$(echo "$PR_JSON" | jq -r '.[0].url') PR_NUMBER=$(echo "$PR_JSON" | jq -r '.[0].number')
Additional context
Also, this would improve CLI API consistency