-
Notifications
You must be signed in to change notification settings - Fork 7.4k
api command: support {owner} and {repo} placeholders
#1165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When `{owner}` and `{repo}` strings are found in request path (for REST
requests) or `query` (for GraphQL), they are replaced with values from
the repository of the current working directory.
vilmibm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excellent 👍
I don't have a better alternative to suggest and I see nothing wrong with the |
|
@mislav did you want to push commits for updating docs? or should I merge this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be very handy. My only concern is the single {} around the vars. It is almost certainly fine, but it doesn't look like a replacement to me. For me, using the GitHub api doc format of /:user/:repo or double curlys /{{user}}/{{repo}} would be a stronger signal to recognize that they will be replaced.
|
@probablycorey Good point! How do you feel about this synax: $ gh api repos/:owner/:repo/releases
# populate `:owner`, `:repo` into the query via GraphQL variables
$ gh api graphql -F owner=:owner -F repo=:repo -f query='
query(owner: $owner, name: $repo) {
repository(owner: $owner, name: $repo) {
releases { ... }
}
}
'Or I could get behind $ gh api repos/{{owner}}/{{repo}}/releases
$ gh api graphql -f query='
{
repository(owner: "{{owner}}", name: "{{repo}}") {
releases { ... }
}
}
'@vilmibm I wanted to update the docs myself once we have resolution on the syntax. |
|
We ended up on: $ gh api repos/:owner/:repo/releases
$ gh api graphql -F owner=:owner -F repo=:repo -f query='
query($owner: String!, $repo: String!) {
repository(owner: $owner, name: $repo) {
releases { ... }
}
}
' |
When
:ownerand:repostrings are found in request path (for REST requests) or--field, -Fvalues, expand them with appropriate values for the current repository. This makes it easier to make requests against local repositories without having to spell out the full repository name.Examples:
TODO:
repos/:owner/:reposyntax, which I think looks nice in URLs, but likely odd anywhere else (such as in a GraphQL query).apicommand docsRef. #332