|
|
@ -0,0 +1,34 @@
|
|
|
1
|
# unpaginate
|
|
|
2
|
|
|
|
3
|
`unpaginate` unpaginates JSON resources.
|
|
|
4
|
|
|
|
5
|
The requested resource is assumed to return an array of JSON
|
|
|
6
|
objects. `unpaginate` prints a new array containing the JSON
|
|
|
7
|
objects from all pages on stdout.
|
|
|
8
|
|
|
|
9
|
Pagination is assumed to be in the format that the GitHub v3
|
|
|
10
|
API uses:
|
|
|
11
|
|
|
|
12
|
```http
|
|
|
13
|
HTTP/1.1 200 OK
|
|
|
14
|
...
|
|
|
15
|
Link: <https://api.github.com/user/527119/repos?per_page=42&page=2>; rel="next", <https://api.github.com/user/527119/repos?per_page=42&page=2>; rel="last"
|
|
|
16
|
```
|
|
|
17
|
|
|
|
18
|
## Usage
|
|
|
19
|
|
|
|
20
|
```
|
|
|
21
|
$ ./unpaginate https://api.github.com/users/heyLu/repos
|
|
|
22
|
...
|
|
|
23
|
|
|
|
24
|
$ ./unpaginate -user heyLu:$token https://api.github.com/user/repos
|
|
|
25
|
...
|
|
|
26
|
```
|
|
|
27
|
|
|
|
28
|
Note that the resources must return *arrays* of JSON objects. Any other
|
|
|
29
|
kind of input will break `unpaginate`, sometimes in unexpected ways.
|
|
|
30
|
|
|
|
31
|
`unpaginate` was written to be used with [stars][], but is hopefully
|
|
|
32
|
also useful in other contexts.
|
|
|
33
|
|
|
|
34
|
[stars]: https://github.com/heyLu/lp/tree/master/go/stars
|