diff options
author | typebrook <typebrook@gmail.com> | 2020-01-22 10:05:43 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2020-01-22 10:05:43 +0800 |
commit | 74752dce17c9cbbdc2d9f7db9cee640d86661c8b (patch) | |
tree | cfddd42150cb9efda9ad4d238cd63195aedb0c41 | |
parent | c3a71fb3d2f34c196a22fe41294a08326a592df3 (diff) |
update
-rwxr-xr-x | scripts/gist | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/scripts/gist b/scripts/gist index 9654a49..2fc5624 100755 --- a/scripts/gist +++ b/scripts/gist | |||
@@ -52,11 +52,10 @@ | |||
52 | # TODO parallel branch works with json parsing on python | 52 | # TODO parallel branch works with json parsing on python |
53 | # TODO parallel branch works with wget and other stuff | 53 | # TODO parallel branch works with wget and other stuff |
54 | # TODO completion | 54 | # TODO completion |
55 | # define your environmemnts here | 55 | |
56 | #------------------- | 56 | # Validate settings. |
57 | folder=~/git/gist | ||
58 | config=~/.config/gistrc | 57 | config=~/.config/gistrc |
59 | #------------------- | 58 | [ "$TRACE" ] && set -x |
60 | 59 | ||
61 | # TODO error handling while password is not true | 60 | # TODO error handling while password is not true |
62 | _auth() { | 61 | _auth() { |
@@ -83,13 +82,11 @@ done | |||
83 | 82 | ||
84 | github_api=https://api.github.com | 83 | github_api=https://api.github.com |
85 | auth_header="Authorization: token $github_api_token" | 84 | auth_header="Authorization: token $github_api_token" |
85 | [[ -z $folder ]] && folder=~/git/gist | ||
86 | mkdir -p $folder | 86 | mkdir -p $folder |
87 | index=$folder/index | 87 | index=$folder/index |
88 | starred=$folder/starred | 88 | starred=$folder/starred |
89 | 89 | ||
90 | # Validate settings. | ||
91 | [ "$TRACE" ] && set -x | ||
92 | |||
93 | # Show the list of gist, but not updated time | 90 | # Show the list of gist, but not updated time |
94 | # TODO show git status outdated | 91 | # TODO show git status outdated |
95 | _show_list() { | 92 | _show_list() { |
@@ -275,14 +272,20 @@ _help_message() { | |||
275 | sed -E -n ' /^$/ q; 8,$ s/^#//p' $0 | 272 | sed -E -n ' /^$/ q; 8,$ s/^#//p' $0 |
276 | } | 273 | } |
277 | 274 | ||
275 | # TODO consider the case that $2 is empty -> remove original setting | ||
278 | _configure() { | 276 | _configure() { |
277 | [[ -z "$@" ]] && vim $config && exit 0 &> /dev/null | ||
279 | case "$1 $2" in | 278 | case "$1 $2" in |
280 | auto_sync[[:space:]]*) echo -n $1 ;;& | 279 | token[[:space:]]????????????????????????????????????????) |
281 | *true) echo =$2;; | 280 | echo $1=$2 ;; |
282 | *false) echo =$2;; | 281 | auto_sync[[:space:]]true) echo $1=$2 ;; |
283 | folder) echo -n $1=$2 ;; | 282 | auto_sync[[:space:]]false) echo $1=$2 ;; |
283 | folder[[:space:]]*) echo $1=$2 ;; | ||
284 | *) echo Not well formated && exit 0;; | ||
284 | esac >> $config | 285 | esac >> $config |
285 | sed -i "$ q; /^$1=/ d" $config | 286 | sed -i "$ q; /^$1=/ d" $config |
287 | |||
288 | cat $config | ||
286 | } | 289 | } |
287 | 290 | ||
288 | case "$1" in | 291 | case "$1" in |