diff options
| author | typebrook <typebrook@gmail.com> | 2020-03-13 11:43:12 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-03-13 11:43:12 +0800 |
| commit | a9139a8c5e7158cd96809cd0ae62e3a1ca56b5d6 (patch) | |
| tree | 91d80b38e316e0043a3271ab5e392ffb71a4c0c9 | |
| parent | 8ed80fe2329d7a79ae7f248c53da0dbd0d66f71e (diff) | |
Return false instantly when given id is not valid
| -rwxr-xr-x | gist | 12 |
1 files changed, 6 insertions, 6 deletions
| @@ -284,14 +284,14 @@ _grep_content() { | |||
| 284 | 284 | ||
| 285 | # Open Github repository import page | 285 | # Open Github repository import page |
| 286 | _import_to_github() { | 286 | _import_to_github() { |
| 287 | _gist_id "$1" | 287 | _gist_id "$1" || return 1 |
| 288 | echo put the folowing URL into web page: | 288 | echo put the folowing URL into web page: |
| 289 | echo -n "git@github.com:$GIST_ID.git" | 289 | echo -n "git@github.com:$GIST_ID.git" |
| 290 | python -mwebbrowser https://github.com/new/import | 290 | python -mwebbrowser https://github.com/new/import |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | _push_to_remote() { | 293 | _push_to_remote() { |
| 294 | _gist_id "$1" | 294 | _gist_id "$1" || return 1 |
| 295 | cd "$folder/$GIST_ID" && git add . \ | 295 | cd "$folder/$GIST_ID" && git add . \ |
| 296 | && git commit --allow-empty-message -m '' && git push origin master | 296 | && git commit --allow-empty-message -m '' && git push origin master |
| 297 | } | 297 | } |
| @@ -398,7 +398,7 @@ _gist_id() { | |||
| 398 | echo -e "Not a valid index: \e[31m$1\e[0m" | 398 | echo -e "Not a valid index: \e[31m$1\e[0m" |
| 399 | echo 'Use the index in the first column instead (like 1 or s1):' | 399 | echo 'Use the index in the first column instead (like 1 or s1):' |
| 400 | echo | 400 | echo |
| 401 | _show_list | 401 | hint=false _show_list |
| 402 | return 1 | 402 | return 1 |
| 403 | fi | 403 | fi |
| 404 | } | 404 | } |
| @@ -436,7 +436,7 @@ _delete_gist() { | |||
| 436 | fi | 436 | fi |
| 437 | 437 | ||
| 438 | for i in "$@"; do | 438 | for i in "$@"; do |
| 439 | _gist_id "$i" | 439 | _gist_id "$i" || continue |
| 440 | http_method DELETE "$GITHUB_API/gists/$GIST_ID" \ | 440 | http_method DELETE "$GITHUB_API/gists/$GIST_ID" \ |
| 441 | && echo "$i" deleted \ | 441 | && echo "$i" deleted \ |
| 442 | && sed -E -i'' -e "/^$i / d" $INDEX | 442 | && sed -E -i'' -e "/^$i / d" $INDEX |
| @@ -482,7 +482,7 @@ for comment in raw: | |||
| 482 | } | 482 | } |
| 483 | 483 | ||
| 484 | _show_detail() { | 484 | _show_detail() { |
| 485 | _gist_id "$1" | 485 | _gist_id "$1" || return 1 |
| 486 | http_method GET "$GITHUB_API/gists/$GIST_ID" \ | 486 | http_method GET "$GITHUB_API/gists/$GIST_ID" \ |
| 487 | | _parse_gist | 487 | | _parse_gist |
| 488 | 488 | ||
| @@ -564,7 +564,7 @@ _create_gist() { | |||
| 564 | 564 | ||
| 565 | # update description of a gist | 565 | # update description of a gist |
| 566 | _edit_gist() { | 566 | _edit_gist() { |
| 567 | _gist_id "$1" | 567 | _gist_id "$1" || return 1 |
| 568 | 568 | ||
| 569 | if [[ -z $2 ]]; then | 569 | if [[ -z $2 ]]; then |
| 570 | echo 'Type new description:' | 570 | echo 'Type new description:' |