diff options
| author | typebrook <typebrook@gmail.com> | 2020-01-22 11:24:16 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-01-22 11:24:16 +0800 |
| commit | 300eb7fffb79f615dd9f8231e1eff91b8cee973f (patch) | |
| tree | f8382778985bcef57df15902a6e0f3ab7504c3a9 | |
| parent | 74752dce17c9cbbdc2d9f7db9cee640d86661c8b (diff) | |
update
| -rwxr-xr-x | scripts/gist | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/scripts/gist b/scripts/gist index 2fc5624..de9ec6f 100755 --- a/scripts/gist +++ b/scripts/gist | |||
| @@ -48,6 +48,7 @@ | |||
| 48 | # * show this help message | 48 | # * show this help message |
| 49 | # gist (help | h) | 49 | # gist (help | h) |
| 50 | 50 | ||
| 51 | # TODO pipe syntax fix | ||
| 51 | # TODO error handling, unit test | 52 | # TODO error handling, unit test |
| 52 | # TODO parallel branch works with json parsing on python | 53 | # TODO parallel branch works with json parsing on python |
| 53 | # TODO parallel branch works with wget and other stuff | 54 | # TODO parallel branch works with wget and other stuff |
| @@ -82,12 +83,14 @@ done | |||
| 82 | 83 | ||
| 83 | github_api=https://api.github.com | 84 | github_api=https://api.github.com |
| 84 | auth_header="Authorization: token $github_api_token" | 85 | auth_header="Authorization: token $github_api_token" |
| 85 | [[ -z $folder ]] && folder=~/git/gist | 86 | |
| 87 | [[ -z "$folder" ]] && folder=~/git/gist | ||
| 86 | mkdir -p $folder | 88 | mkdir -p $folder |
| 87 | index=$folder/index | 89 | index=$folder/index |
| 88 | starred=$folder/starred | 90 | starred=$folder/starred |
| 89 | 91 | ||
| 90 | # Show the list of gist, but not updated time | 92 | # Show the list of gist, but not updated time |
| 93 | # TODO a way to show files | ||
| 91 | # TODO show git status outdated | 94 | # TODO show git status outdated |
| 92 | _show_list() { | 95 | _show_list() { |
| 93 | if [[ ! -e "$1" ]]; then | 96 | if [[ ! -e "$1" ]]; then |
| @@ -274,14 +277,14 @@ _help_message() { | |||
| 274 | 277 | ||
| 275 | # TODO consider the case that $2 is empty -> remove original setting | 278 | # TODO consider the case that $2 is empty -> remove original setting |
| 276 | _configure() { | 279 | _configure() { |
| 277 | [[ -z "$@" ]] && vim $config && exit 0 &> /dev/null | 280 | [[ -z "$@" ]] && vim $config && exit 0 &> /dev/null ||\ |
| 281 | echo edit file $config directly && exit 0 | ||
| 282 | |||
| 278 | case "$1 $2" in | 283 | case "$1 $2" in |
| 279 | token[[:space:]]????????????????????????????????????????) | 284 | token) echo github_api_token=$2 ;; |
| 280 | echo $1=$2 ;; | ||
| 281 | auto_sync[[:space:]]true) echo $1=$2 ;; | ||
| 282 | auto_sync[[:space:]]false) echo $1=$2 ;; | 285 | auto_sync[[:space:]]false) echo $1=$2 ;; |
| 283 | folder[[:space:]]*) echo $1=$2 ;; | 286 | folder[[:space:]]*) echo $1=$2 ;; |
| 284 | *) echo Not well formated && exit 0;; | 287 | *) echo Not well formated; exit 0;; |
| 285 | esac >> $config | 288 | esac >> $config |
| 286 | sed -i "$ q; /^$1=/ d" $config | 289 | sed -i "$ q; /^$1=/ d" $config |
| 287 | 290 | ||
| @@ -290,7 +293,7 @@ _configure() { | |||
| 290 | 293 | ||
| 291 | case "$1" in | 294 | case "$1" in |
| 292 | "") | 295 | "") |
| 293 | _show_list $index ;; | 296 | show_list $index ;; |
| 294 | star | s) | 297 | star | s) |
| 295 | _show_list $starred ;; | 298 | _show_list $starred ;; |
| 296 | update | u) | 299 | update | u) |