@@ -71,7 +71,7 @@ func NewCmdApi(f *cmdutil.Factory, runF func(*ApiOptions) error) *cobra.Command
7171 The endpoint argument should either be a path of a GitHub API v3 endpoint, or
7272 "graphql" to access the GitHub API v4.
7373
74- Placeholder values ": owner", ": repo", and ": branch" in the endpoint argument will
74+ Placeholder values "{ owner} ", "{ repo} ", and "{ branch} " in the endpoint argument will
7575 get replaced with values from the repository of the current directory.
7676
7777 The default HTTP request method is "GET" normally and "POST" if any parameters
@@ -87,7 +87,7 @@ func NewCmdApi(f *cmdutil.Factory, runF func(*ApiOptions) error) *cobra.Command
8787
8888 - literal values "true", "false", "null", and integer numbers get converted to
8989 appropriate JSON types;
90- - placeholder values ": owner", ": repo", and ": branch" get populated with values
90+ - placeholder values "{ owner} ", "{ repo} ", and "{ branch} " get populated with values
9191 from the repository of the current directory;
9292 - if the value starts with "@", the rest of the value is interpreted as a
9393 filename to read the value from. Pass "-" to read from standard input.
@@ -106,10 +106,10 @@ func NewCmdApi(f *cmdutil.Factory, runF func(*ApiOptions) error) *cobra.Command
106106 ` , "`" ),
107107 Example : heredoc .Doc (`
108108 # list releases in the current repository
109- $ gh api repos/: owner/: repo/releases
109+ $ gh api repos/{ owner}/{ repo} /releases
110110
111111 # post an issue comment
112- $ gh api repos/: owner/: repo/issues/123/comments -f body='Hi from CLI'
112+ $ gh api repos/{ owner}/{ repo} /issues/123/comments -f body='Hi from CLI'
113113
114114 # add parameters to a GET request
115115 $ gh api -X GET search/issues -f q='repo:cli/cli is:open remote'
@@ -121,14 +121,14 @@ func NewCmdApi(f *cmdutil.Factory, runF func(*ApiOptions) error) *cobra.Command
121121 $ gh api --preview baptiste,nebula ...
122122
123123 # print only specific fields from the response
124- $ gh api repos/: owner/: repo/issues --jq '.[].title'
124+ $ gh api repos/{ owner}/{ repo} /issues --jq '.[].title'
125125
126126 # use a template for the output
127- $ gh api repos/: owner/: repo/issues --template \
127+ $ gh api repos/{ owner}/{ repo} /issues --template \
128128 '{{range .}}{{.title}} ({{.labels | pluck "name" | join ", " | color "yellow"}}){{"\n"}}{{end}}'
129129
130130 # list releases with GraphQL
131- $ gh api graphql -F owner=': owner' -F name=': repo' -f query='
131+ $ gh api graphql -F owner='{ owner} ' -F name='{ repo} ' -f query='
132132 query($name: String!, $owner: String!) {
133133 repository(owner: $owner, name: $name) {
134134 releases(last: 3) {
@@ -397,9 +397,9 @@ func processResponse(resp *http.Response, opts *ApiOptions, headersOutputStream
397397 return
398398}
399399
400- var placeholderRE = regexp .MustCompile (`\:(owner|repo|branch)\b` )
400+ var placeholderRE = regexp .MustCompile (`( \:(owner|repo|branch)\b|\{(owner|repo|branch)\}) ` )
401401
402- // fillPlaceholders populates `: owner` and `: repo` placeholders with values from the current repository
402+ // fillPlaceholders populates `{ owner} ` and `{ repo} ` placeholders with values from the current repository
403403func fillPlaceholders (value string , opts * ApiOptions ) (string , error ) {
404404 if ! placeholderRE .MatchString (value ) {
405405 return value , nil
@@ -412,11 +412,11 @@ func fillPlaceholders(value string, opts *ApiOptions) (string, error) {
412412
413413 filled := placeholderRE .ReplaceAllStringFunc (value , func (m string ) string {
414414 switch m {
415- case ":owner" :
415+ case ":owner" , "{owner}" :
416416 return baseRepo .RepoOwner ()
417- case ":repo" :
417+ case ":repo" , "{repo}" :
418418 return baseRepo .RepoName ()
419- case ":branch" :
419+ case ":branch" , "{branch}" :
420420 branch , e := opts .Branch ()
421421 if e != nil {
422422 err = e
0 commit comments