@@ -72,10 +72,12 @@ func NewCmdApi(f *cmdutil.Factory, runF func(*ApiOptions) error) *cobra.Command
7272 The endpoint argument should either be a path of a GitHub API v3 endpoint, or
7373 "graphql" to access the GitHub API v4.
7474
75- Placeholder values "{owner}", "{repo}", and "{branch}" in the endpoint argument will
76- get replaced with values from the repository of the current directory. Note that in
77- some shells, for example PowerShell, you may need to enclose any value that contains
78- "{...}" in quotes to prevent the shell from applying special meaning to curly braces.
75+ Placeholder values "{owner}", "{repo}", and "{branch}" in the endpoint
76+ argument will get replaced with values from the repository of the current
77+ directory or the repository specified in the GH_REPO environment variable.
78+ Note that in some shells, for example PowerShell, you may need to enclose
79+ any value that contains "{...}" in quotes to prevent the shell from
80+ applying special meaning to curly braces.
7981
8082 The default HTTP request method is "GET" normally and "POST" if any parameters
8183 were added. Override the method with %[1]s--method%[1]s.
@@ -168,6 +170,9 @@ func NewCmdApi(f *cmdutil.Factory, runF func(*ApiOptions) error) *cobra.Command
168170 ` ),
169171 },
170172 Args : cobra .ExactArgs (1 ),
173+ PreRun : func (c * cobra.Command , args []string ) {
174+ opts .BaseRepo = cmdutil .OverrideBaseRepoFunc (f , "" )
175+ },
171176 RunE : func (c * cobra.Command , args []string ) error {
172177 opts .RequestPath = args [0 ]
173178 opts .RequestMethodPassed = c .Flags ().Changed ("method" )
0 commit comments