aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-03-13 15:49:36 +0800
committertypebrook <typebrook@gmail.com>2020-03-13 15:49:36 +0800
commit26d6f84442360b0f49be63e2e57ae4b497f22f5c (patch)
treed0d4972e9f67833e0125a25aec2ed3362117c80c
parent299c28943077b14d42938c2ade009a1647acde14 (diff)
Add error message for gist config
-rwxr-xr-xgist9
1 files changed, 4 insertions, 5 deletions
diff --git a/gist b/gist
index 6b1776e..1cadc26 100755
--- a/gist
+++ b/gist
@@ -154,14 +154,13 @@ _configure() {
154 local valid_keys='user|token|folder|auto_sync|EDITOR|action|protocol' 154 local valid_keys='user|token|folder|auto_sync|EDITOR|action|protocol'
155 if [[ $1 =~ ^($valid_keys)$ ]]; then 155 if [[ $1 =~ ^($valid_keys)$ ]]; then
156 if [[ $1 == 'user' ]]; then 156 if [[ $1 == 'user' ]]; then
157 [[ -z $2 ]] && echo "Must specify username" >&2 && return 1 157 [[ -z $2 ]] && echo 'Must specify username' >&2 && return 1
158 elif [[ $1 == 'token' ]]; then 158 elif [[ $1 == 'token' ]]; then
159 [[ ${#2} -ne 40 ]] && echo 'Invalid token format, it is not 40 chars' >&2 \ 159 [[ ${#2} -ne 40 ]] && echo 'Invalid token format, it is not 40 chars' >&2 && return 1
160 && return 1
161 elif [[ $1 == 'auto_sync' ]]; then 160 elif [[ $1 == 'auto_sync' ]]; then
162 [[ ! $2 =~ ^(true|false)$ ]] && return 1 161 [[ ! $2 =~ ^(true|false)$ ]] && echo 'auto_sync must be either true or false' >&2 && return 1
163 elif [[ $1 == 'protocol' ]]; then 162 elif [[ $1 == 'protocol' ]]; then
164 [[ ! $2 =~ ^(https|ssh)$ ]] && return 1 163 [[ ! $2 =~ ^(https|ssh)$ ]] && echo 'protocol must be either https or ssh' >&2 && return 1
165 fi 164 fi
166 local key=$1 && shift && local target=$key="'$*'" 165 local key=$1 && shift && local target=$key="'$*'"
167 else 166 else