aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-03-18 18:28:23 +0800
committertypebrook <typebrook@gmail.com>2020-03-19 11:07:55 +0800
commit2b32e172863df8b272b4c4c4d69ea8226e0aec95 (patch)
tree13510272ac9fe67dd2f0f9ba63e3eeb7338a409c
parente1c9027186a05f25a72736d115436c6492adb18d (diff)
Modify parameter for 'gist delete'
Use environment variable is too risky here
-rw-r--r--README.md2
-rwxr-xr-xgist8
2 files changed, 5 insertions, 5 deletions
diff --git a/README.md b/README.md
index fa2b7f3..da70fdb 100644
--- a/README.md
+++ b/README.md
@@ -165,7 +165,7 @@ hint=false gist
165gist 3 --no-action 165gist 3 --no-action
166 166
167# delete your third gist without confirmation 167# delete your third gist without confirmation
168confirm=false gist delete 3 168gist delete 3 --force
169``` 169```
170 170
171 171
diff --git a/gist b/gist
index a6d8f04..4741fbd 100755
--- a/gist
+++ b/gist
@@ -16,7 +16,7 @@
16# new, n [-d | --desc <description>] [-p] [-f | --file <file_name>] create a new gist from STDIN 16# new, n [-d | --desc <description>] [-p] [-f | --file <file_name>] create a new gist from STDIN
17# detail, d <index_of_gist> Show the detail of a gist 17# detail, d <index_of_gist> Show the detail of a gist
18# edit, e <index_of_gist> Edit a gist's description 18# edit, e <index_of_gist> Edit a gist's description
19# delete, D <index_of_gist>... Delete a gist 19# delete, D <index_of_gist>... [--force] Delete a gist
20# clean, C Clean removed gists in local 20# clean, C Clean removed gists in local
21# config, c [token | user | folder | auto_sync | EDITOR | action | protocol [value] ] Do configuration 21# config, c [token | user | folder | auto_sync | EDITOR | action | protocol [value] ] Do configuration
22# user, U <user> Get gists from a given Github user 22# user, U <user> Get gists from a given Github user
@@ -456,16 +456,16 @@ _goto_gist() {
456} 456}
457 457
458# Delete gists with given indices 458# Delete gists with given indices
459# Specify confirm=false to suppress confirmation 459# Specify --force to suppress confirmation
460_delete_gist() { 460_delete_gist() {
461 if [[ $confirm != false ]]; then 461 if [[ ! $* =~ '--force' ]]; then
462 read -r -p "Delete gists above? [y/N] " response 462 read -r -p "Delete gists above? [y/N] " response
463 response=${response,,} 463 response=${response,,}
464 [[ ! $response =~ ^(yes|y)$ ]] && return 0 464 [[ ! $response =~ ^(yes|y)$ ]] && return 0
465 fi 465 fi
466 466
467 for i in "$@"; do 467 for i in "$@"; do
468 _gist_id "$i" || continue 468 _gist_id "$i" &> /dev/null || continue
469 http_method DELETE "$GITHUB_API/gists/$GIST_ID" \ 469 http_method DELETE "$GITHUB_API/gists/$GIST_ID" \
470 && echo "$i" deleted \ 470 && echo "$i" deleted \
471 && sed -E -i'' -e "/^$i / d" $INDEX 471 && sed -E -i'' -e "/^$i / d" $INDEX