i wanted to play a bit with the new unfold
command introduced by @hudclark in nushell/nushell#10489 and went with a gist listing task π
π‘ Note
see nushell/nushell#10630
def "gh list gists" [
user: string, # the user to list all the Gists of
--page-size: int = 100, # the number of Gists per page
]: nothing -> table<url: string, forks_url: string, commits_url: string, id: string, node_id: string, git_pull_url: string, git_push_url: string, html_url: string, files record, public: bool, created_at: string, updated_at: string, description: string, comments: int, user: nothing, comments_url: string, owner: record<login: string, id: int, node_id: string, avatar_url: string, gravatar_id: string, url: string, html_url: string, followers_url: string, following_url: string, gists_url: string, starred_url: string, subscriptions_url: string, organizations_url: string, repos_url: string, events_url: string, received_events_url: string, type: string, site_admin: bool>, truncated: bool, page: int> {
unfold 1 { |page|
print $"getting page ($page)..."
let resp = http get (
{
scheme: https,
host: "api.github.com",
path: $"/users/($user)/gists",
params: {
page: $page,
per_page: $page_size
}
} | url join)
if ($resp | length) < $page_size {
{out: $resp}
} else {
{out: $resp, next: ($page + 1)}
}
}
| enumerate
| each {|it| $it.item | insert page $it.index}
| flatten
}
gh list gists "amtoine" | select id description
and the output
getting page 1...
#ββ¬βββββββββββββββidββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββdescriptionββββββββββββββββββββββββββββββββββββββ
0 β3fe1435edb656964d8066b5b7da9af5fβPlot startup times of Nushell
1 β535f21c16a8c1ebeb180db2c49c494b4βNushell dependency graph
2 β9531ea725991177ac9e2dcfe19193c5eβ`arkworks-rs` dependency graph
3 βd3f216b30ff331d1765702172b4eeafcβcompare HTTP files
4 β84ad5a5d760c91393d58c22c02c358b6βauto update from HTTP file
5 βa46c5cb1da94b3f0791b735663c03d9eβinspect all nushell issues
6 βe3e4d75f6d0bd3b3a439077df1380421βa wrapper around the `gstat` plugin for `nushell`
7 βc68b9d5122454f0c2d2bc626d5e491f9βlist contributions in a *GitHub* repo
8 β4c748237ccd09a4ad745ed46d87fea3dβmake a system alias
9 βbe49729de499efdffa57e21b3bbc5c45βmeasure completion impact on the startup time of `nushell`
10βeee36e71a0a4b40a9ad3a8e5d4785341βpull github repos without `gh` CLI
11βd24a14956eb61c5c1a06df57dcd8dadeβlist `nushell` search terms
12β8b028e16747bf7f850a8f55cfc4c1327βlist contributions between PRs
13βa2d45c6a804d61280a31a9ffc4b69910βa PNG parser for `nushell`
14β9384a03b428edbd85324e6f8ac099a58βSome tips and observations on my journey on Ubuntu for my job
15β69c8be3dd38ec75afb86da78210c524dβThe JS source from "Juan Benet: Enter the Merkle Forest" (https://youtu.be/Bqs_LzBjQyk)
βββ΄βββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ