diff --git a/README.md b/README.md index 893bb67..b8c4f3c 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -78,13 +78,14 @@ $ gh contribs gh contribs --help ``` ``` -Usage: gh contribs [-h] [-s ] [-g ] [-w ] [-x] [-y] [-d] [-l] [-p] [-D] [-W] +Usage: gh contribs [-h] [-s ] [-g ] [-u ] [-w ] [-x] [-y] [-d] [-l] [-p] [-D] [-W] Arguments: -h | --help Displays this help. -s | --scheme Color Scheme -g | --glyph Change Character + -u | --user Show graph for other users -w | --weeks Set range of weeks to be displayed -x | --xgap Remove Gap between each Column -y | --ygap Put a Gap between each Row diff --git a/gh-contribs b/gh-contribs index 8d63763..c0d37d5 100755 --- a/gh-contribs +++ b/gh-contribs @@ -15,6 +15,8 @@ main() glyph=square xgap=" " ygap="\n" + #user="tonsky" + user="" # boolean portrait=1 @@ -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" @@ -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))" @@ -302,7 +328,7 @@ glyph() # msgs h_usage() { - printf "Usage: gh contribs [-h] [-s ] [-g ] [-w ] [-x] [-y] [-d] [-l] [-p] [-D] [-W]\n\n" + printf "Usage: gh contribs [-h] [-s ] [-g ] [-u ] [-w ] [-x] [-y] [-d] [-l] [-p] [-D] [-W]\n\n" return 0 } @@ -326,6 +352,7 @@ h_args() -h | --help Displays this help. -s | --scheme Color Scheme -g | --glyph Change Character + -u | --user Show graph for other users -w | --weeks Set range of weeks to be displayed -x | --xgap Remove Gap between each Column -y | --ygap Put a Gap between each Row