@@ -164,24 +164,26 @@ func getPullRequestDetails(cmd *cobra.Command, args []string) {
164
164
165
165
}
166
166
167
+ var listPullRequestsQueryParams = bitbucketapi.UrlQueryParams {
168
+ bitbucketapi.UrlQueryParam {CmdFlag : "page" , DefaultValue : "1" , ParamKey : "page" },
169
+ bitbucketapi.UrlQueryParam {CmdFlag : "limit" , DefaultValue : "20" , ParamKey : "pagelen" },
170
+ bitbucketapi.UrlQueryParam {CmdFlag : "order" , DefaultValue : "-created_on" , ParamKey : "sort" },
171
+ bitbucketapi.UrlQueryParam {CmdFlag : "state" , DefaultValue : "" , ParamKey : "state" },
172
+ }
173
+
167
174
func listPullRequests (cmd * cobra.Command ) {
168
175
repo , err := githelper .GetCurrentRepo (cmd )
169
176
if err != nil {
170
177
fmt .Println (cliformat .Error ("No repo provided and current directory doesn't have a git remote repo" ))
171
178
return
172
179
}
173
- url := repo + "/pullrequests?pagelen=20&sort=-created_on"
174
-
175
- state , err := cmd .Flags ().GetString ("state" )
176
- if err != nil || state != "" {
177
- url = url + "&state=" + state
178
-
180
+ urlQueryParams , err := bitbucketapi .FormatUrlQueryParam (cmd , listPullRequestsQueryParams )
181
+ if err != nil {
182
+ fmt .Println (cliformat .Error (err .Error ()))
179
183
}
180
- page , err := cmd .Flags ().GetString ("page" )
181
- if err != nil || page != "" {
182
- url = url + "&page=" + page
183
184
184
- }
185
+ url := repo + "/pullrequests?" + urlQueryParams
186
+
185
187
resp , err := bitbucketapi .HttpRequestWithBitbucketAuthJson ("GET" , url , map [string ]string {})
186
188
187
189
defer resp .Body .Close ()
@@ -323,6 +325,8 @@ func init() {
323
325
pullRequestsCmd .Flags ().StringP ("page" , "p" , "" , "Page number for pullreuest pagination" )
324
326
pullRequestsCmd .Flags ().StringP ("format" , "f" , "" , "Output template format" )
325
327
pullRequestsCmd .Flags ().BoolP ("json" , "j" , false , "Output as json" )
328
+ pullRequestsCmd .Flags ().StringP ("order" , "o" , "" , "Order by" )
329
+ pullRequestsCmd .Flags ().StringP ("limit" , "l" , "" , "Page length (pagelen) param" )
326
330
pullRequestsCmd .Flags ().StringP ("state" , "s" , "" , "Pull request state" )
327
331
pullRequestCreateCmd .Flags ().StringP ("source" , "s" , "" , "Pull request source branch" )
328
332
pullRequestCreateCmd .Flags ().StringP ("title" , "t" , "" , "Pull request title" )
0 commit comments