From c68b07ab292257be868406a4e486b1bc7fe44292 Mon Sep 17 00:00:00 2001 From: typebrook Date: Sun, 9 Feb 2020 17:09:58 +0800 Subject: update --- scripts/gist | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'scripts/gist') diff --git a/scripts/gist b/scripts/gist index 29bb1e1..a67eca6 100755 --- a/scripts/gist +++ b/scripts/gist @@ -202,7 +202,7 @@ _validate_config(){ echo 'To create/edit/delete a gist, a token is needed' return 1 fi - elif [[ -z $token && $1 =~ ^(u|update)$ && $2 =~ ^(s|star) ]]; then + elif [[ -z $token && $1 =~ ^(f|fetch)$ && $2 =~ ^(s|star) ]]; then if ! (_ask_token); then echo 'To get user starred gists, a token is needed' return 1 @@ -239,8 +239,8 @@ _show_list() { echo ' gist update' return 0 fi - [[ -z $1 ]] && local filter='/^ *s/ d; /^$/ d' - [[ $1 == "s" ]] && local filter='/^ *[^ s]/ d; /^$/ d' + local filter='/^ *s/ d; /^$/ d' + [[ $mark == "s" ]] && filter='/^ *[^ s]/ d; /^$/ d' sed -e "$filter" $INDEX \ | while read index link blob_code file_num comment_num author description; do @@ -307,19 +307,18 @@ _fetch_gists() { echo "fetching $user's gists from $GITHUB_API..." echo local route="users/$user/gists" - local mark="" local filter='/^[^s]/ d; /^$/ d' if [[ "$1" =~ ^(star|s)$ ]];then route="gists/starred" - mark="s" + local mark="s" filter='/^[s]/ d; /^$/ d' fi - result=$(http_method GET $GITHUB_API/$route | _parse_response) + result=$(http_method GET $GITHUB_API/$route | mark=$mark _parse_response) [[ -z $result ]] && echo Failed to update gists && return 1 sed -i'' -e "$filter" $INDEX && echo "$result" >> $INDEX - _show_list $mark + mark=$mark _show_list if [[ $auto_sync != 'false' ]]; then (_sync_repos $1 > /dev/null 2>&1 &); fi } @@ -546,7 +545,7 @@ case "$1" in "") _show_list ;; star | s) - _show_list s ;; + mark=s _show_list ;; fetch | f) _fetch_gists "$2" ;; new | n) -- cgit v1.2.3-70-g09d2