aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-05-11 21:43:52 +0800
committertypebrook <typebrook@gmail.com>2020-05-11 21:43:52 +0800
commit4090e15269842705b335885bfcb8294127ff2f0e (patch)
tree57b2d2f08e7b016dd910d147edc33d28db9922f0
parentbce48aa18a848c6bde53ea9635146e239a1307c3 (diff)
Refactor code
-rwxr-xr-xgist6
1 files changed, 3 insertions, 3 deletions
diff --git a/gist b/gist
index 80ecdcc..c46b84d 100755
--- a/gist
+++ b/gist
@@ -245,7 +245,7 @@ _ask_token() {
245} 245}
246 246
247# Check configuration is fine with user setting 247# Check configuration is fine with user setting
248_validate_config(){ 248_validate_config() {
249 # shellcheck source=/dev/null 249 # shellcheck source=/dev/null
250 source "$CONFIG" 2> /dev/null 250 source "$CONFIG" 2> /dev/null
251 [[ $1 =~ ^(c|config|h|help|u|user|update|version) ]] && return 0 251 [[ $1 =~ ^(c|config|h|help|u|user|update|version) ]] && return 0
@@ -257,7 +257,7 @@ _validate_config(){
257 elif [[ -z $token && $1 =~ ^(n|new|e|edit|D|delete)$ ]]; then 257 elif [[ -z $token && $1 =~ ^(n|new|e|edit|D|delete)$ ]]; then
258 _ask_token && return 0 258 _ask_token && return 0
259 echo 'To create/edit/delete a gist, a token is needed' && return 1 259 echo 'To create/edit/delete a gist, a token is needed' && return 1
260 elif [[ -z $token && $1 =~ ^(f|fetch)$ && $2 =~ ^(s|star) ]]; then 260 elif [[ -z $token && $1 =~ ^(f|fetch)$ && $2 =~ ^(s|star)$ ]]; then
261 _ask_token && return 0 261 _ask_token && return 0
262 echo 'To get user starred gists, a token is needed' && return 1 262 echo 'To get user starred gists, a token is needed' && return 1
263 fi 263 fi
@@ -852,7 +852,7 @@ case "$1" in
852 all | a) 852 all | a)
853 mark=.; _show_list ;; 853 mark=.; _show_list ;;
854 fetch | f) 854 fetch | f)
855 [[ $2 =~ ^[s|star]$ ]] && mark=s || mark=[^s] 855 [[ $2 =~ ^(s|star)$ ]] && mark=s || mark=[^s]
856 _fetch_gists ;; 856 _fetch_gists ;;
857 new | n) 857 new | n)
858 shift 858 shift