Add the api --preview flag to opt into GitHub API previews#3077
Conversation
This was previously available manually via the `-H` flag, but it was verbose, especially when opting into multiple previews.
|
This is a nice improvement. The preview headers are quite verbose. I think "preview"/"p" are both good since that is what the docs call them and I can't think of another use for the "p" shorthand. From my understanding these previews are only available in the REST API, do we want to add a note about that to the documentation? |
samcoe
left a comment
There was a problem hiding this comment.
I left a couple questions but nothing blocking 👍
| } | ||
|
|
||
| func previewNamesToMIMETypes(names []string) string { | ||
| types := []string{fmt.Sprintf("application/vnd.github.%s-preview+json", names[0])} |
There was a problem hiding this comment.
What is the reason why +json is only appended to the first preview header? I was unable to find anything in the media types docs.
There was a problem hiding this comment.
Good catch! Accept headers can list multiple MIME types, and is sufficient that only one of them specifies the json format, while the others are merely to activate additional previews and need not repeat +json any further.
vilmibm
left a comment
There was a problem hiding this comment.
so excited for this; i do a lot locally with projects and this is going to help a ton.
This was previously available manually via the
-Hflag, but it was verbose, especially when opting into multiple previews.Before:
gh api -H 'Accept: application/vnd.github.nebula-preview+json, application/vnd.github.baptiste-preview, application/vnd.github.squirrel-girl-preview'Now:
I feel like this shorter version lends itself really well to usage via aliases.
Questions:
-pfine as a shorthand or would we want to use it for something else in the near future?