Skip to content

Commit

Permalink
Merge pull request #4 from MintArchit/feat_user
Browse files Browse the repository at this point in the history
feat: add arg user
  • Loading branch information
MintArchit authored Feb 18, 2023
2 parents 071d572 + 01e98a3 commit 020e01a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ connects directly via github api / no third party service is used

## ✨ Features

- [X] other user arg (NEW)
- [X] Color schemes (NEW)
- [X] Orientation Portrait/Landscape (NEW)
- [X] Orientation Portrait/Landscape
- [X] Diffrent Character Glyphs
- [X] Day labels
- [X] Specify weeks
Expand All @@ -30,7 +31,6 @@ connects directly via github api / no third party service is used
- [ ] optimize performance
- [ ] include update notifier
- [ ] add version arg
- [ ] add user arg
- [ ] isolated per-repo graph
- [ ] Show legend, month, and contribution count—separate flags for each

Expand Down Expand Up @@ -78,13 +78,14 @@ $ gh contribs
gh contribs --help
```
```
Usage: gh contribs [-h] [-s <scheme>] [-g <glyph>] [-w <weeks>] [-x] [-y] [-d] [-l] [-p] [-D] [-W]
Usage: gh contribs [-h] [-s <scheme>] [-g <glyph>] [-u <user>] [-w <weeks>] [-x] [-y] [-d] [-l] [-p] [-D] [-W]
Arguments:
-h | --help Displays this help.
-s | --scheme <name> Color Scheme
-g | --glyph <char> Change Character
-u | --user <user> Show graph for other users
-w | --weeks <weeks> Set range of weeks to be displayed
-x | --xgap Remove Gap between each Column
-y | --ygap Put a Gap between each Row
Expand Down
49 changes: 38 additions & 11 deletions gh-contribs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ main()
glyph=square
xgap=" "
ygap="\n"
#user="tonsky"
user=""

# boolean
portrait=1
Expand Down Expand Up @@ -60,20 +62,40 @@ main()


# gh api
days=( $(gh api graphql -f query='{
viewer {
contributionsCollection {
contributionCalendar {
weeks {
contributionDays {
color
if [[ -z "$user" ]]; then
days=( $(gh api graphql -f query='{
viewer {
contributionsCollection {
contributionCalendar {
weeks {
contributionDays {
color
}
}
}
}
}
}
}' --jq '..|.color?' | grep .) )
#}' --gache 24h --jq '..|.color?' | grep .) )
}' --jq '..|.color?' | grep .) )
else
days=( $(gh api graphql -F "user=$user" -f query='query($user:String!) {
user(login: $user)
{
contributionsCollection
{
contributionCalendar
{
weeks
{
contributionDays
{
color
}
}
}
}
}
}' --jq '..|.color?' | grep .) )
fi

[ $debug -eq 0 ] && printf "terminal: $terminal_width, calculated-output: $output_width\n"

Expand Down Expand Up @@ -109,6 +131,10 @@ parse_args()
glyph="$2"
[ -z $2 ] && h_glyphs >&2 && exit 1
shift 2;;
-u|--user)
user="$2"
[ -z $2 ] && printf "\nError: no username given\n" >&2 && exit 1
shift 2;;
-w|--weeks)
weeks="$2"
weeks_min="$(($weeks_max-weeks))"
Expand Down Expand Up @@ -302,7 +328,7 @@ glyph()
# msgs
h_usage()
{
printf "Usage: gh contribs [-h] [-s <scheme>] [-g <glyph>] [-w <weeks>] [-x] [-y] [-d] [-l] [-p] [-D] [-W]\n\n"
printf "Usage: gh contribs [-h] [-s <scheme>] [-g <glyph>] [-u <user>] [-w <weeks>] [-x] [-y] [-d] [-l] [-p] [-D] [-W]\n\n"
return 0
}

Expand All @@ -326,6 +352,7 @@ h_args()
-h | --help Displays this help.
-s | --scheme <name> Color Scheme
-g | --glyph <char> Change Character
-u | --user <user> Show graph for other users
-w | --weeks <weeks> Set range of weeks to be displayed
-x | --xgap Remove Gap between each Column
-y | --ygap Put a Gap between each Row
Expand Down

0 comments on commit 020e01a

Please sign in to comment.