From 2b32e172863df8b272b4c4c4d69ea8226e0aec95 Mon Sep 17 00:00:00 2001 From: typebrook Date: Wed, 18 Mar 2020 18:28:23 +0800 Subject: Modify parameter for 'gist delete' Use environment variable is too risky here --- README.md | 2 +- gist | 8 ++++---- 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 gist 3 --no-action # delete your third gist without confirmation -confirm=false gist delete 3 +gist delete 3 --force ``` diff --git a/gist b/gist index a6d8f04..4741fbd 100755 --- a/gist +++ b/gist @@ -16,7 +16,7 @@ # new, n [-d | --desc ] [-p] [-f | --file ] create a new gist from STDIN # detail, d Show the detail of a gist # edit, e Edit a gist's description -# delete, D ... Delete a gist +# delete, D ... [--force] Delete a gist # clean, C Clean removed gists in local # config, c [token | user | folder | auto_sync | EDITOR | action | protocol [value] ] Do configuration # user, U Get gists from a given Github user @@ -456,16 +456,16 @@ _goto_gist() { } # Delete gists with given indices -# Specify confirm=false to suppress confirmation +# Specify --force to suppress confirmation _delete_gist() { - if [[ $confirm != false ]]; then + if [[ ! $* =~ '--force' ]]; then read -r -p "Delete gists above? [y/N] " response response=${response,,} [[ ! $response =~ ^(yes|y)$ ]] && return 0 fi for i in "$@"; do - _gist_id "$i" || continue + _gist_id "$i" &> /dev/null || continue http_method DELETE "$GITHUB_API/gists/$GIST_ID" \ && echo "$i" deleted \ && sed -E -i'' -e "/^$i / d" $INDEX -- cgit v1.2.3-70-g09d2