-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlibs.sh
executable file
·44 lines (40 loc) · 1.15 KB
/
libs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
list=""
endCursor=""
is_end="true"
call_star_api(){
# shellcheck disable=SC2016
gh api graphql -F first="$1" -F endCursor="$2" -f query='
query($first: Int, $endCursor: String!){
viewer {
starredRepositories(first: $first, after: $endCursor, orderBy: {field: STARRED_AT, direction: DESC}) {
edges {
node {
nameWithOwner
url
}
starredAt
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
'
}
list_stars() {
result=$(call_star_api "$1" "${endCursor}")
list="$(echo $result | jq -r '.data.viewer.starredRepositories.edges[] | [.node.nameWithOwner, (.starredAt|fromdateiso8601|localtime|strflocaltime("%Y-%m-%d %H:%M:%S"))] | @tsv')"
echo "${list}" | column -t -s$'\t'
endCursor=$(echo $result | jq -r '.data.viewer.starredRepositories.pageInfo.endCursor')
is_end=$(echo $result | jq -r '.data.viewer.starredRepositories.pageInfo.hasNextPage')
}
loop_list_stars(){
number=$1
while [ "${is_end}" = "true" ]
do
list_stars $number
done
}