this pulls all GitHub repositories of my @amtoine account, one page after another, without requiring the use of gh.
Created
March 21, 2023 17:38
-
-
Save amtoine/eee36e71a0a4b40a9ad3a8e5d4785341 to your computer and use it in GitHub Desktop.
pull github repos without `gh` CLI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const PAGE_SIZE = 10 | |
| def get-page [page: int] { | |
| http get ({ | |
| scheme: https, | |
| username: "", | |
| password: "", | |
| host: api.github.com, | |
| port: "", | |
| path: /users/amtoine/repos, | |
| fragment: "", | |
| params: { | |
| sort: updated, | |
| per_page: $PAGE_SIZE, | |
| page: $page | |
| } | |
| } | url join) | |
| | select name description | |
| } | |
| mut page_id = 0 | |
| mut page = (seq 1 $PAGE_SIZE) | |
| mut pages = $nothing | |
| while ($page | length) == $PAGE_SIZE { | |
| $page_id = ($page_id + 1) | |
| print $"getting page ($page_id)..." | |
| $page = (get-page $page_id) | |
| $pages = ($pages | append $page) | |
| } | |
| $pages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment