Skip to content

Instantly share code, notes, and snippets.

@amtoine
Created March 21, 2023 17:38
Show Gist options
  • Save amtoine/eee36e71a0a4b40a9ad3a8e5d4785341 to your computer and use it in GitHub Desktop.
Save amtoine/eee36e71a0a4b40a9ad3a8e5d4785341 to your computer and use it in GitHub Desktop.
pull github repos without `gh` CLI

pull github repos without gh CLI

this pulls all GitHub repositories of my @amtoine account, one page after another, without requiring the use of gh.

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