From ad26de81576a733858042513a39d25fd89c7b085 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Thu, 2 Jul 2020 11:41:33 +0800 Subject: Refine 'gist config' - Update helper message - Remove checking for removed command - Print modified configuration after 'gist config' --- gist | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gist b/gist index 47a43bb..3f6b3ba 100755 --- a/gist +++ b/gist @@ -30,7 +30,8 @@ # delete, D ... [--force] Delete gists by given indices # push, P Push changes by git (well, better to make commit by youself) # clean, C Clean local repos of removed gists -# config, c [token|user|folder|auto_sync|EDITOR|action|protocol|show_untagged [value]] Do configuration +# config, c Configure with editor, will show all valid keys +# config, c [value] Configure a single option. If no value is specified, apply default setting # user, u Get list of gists with a given Github user # github, G Export selected gist as a new Github repo # help, h Show this help message @@ -195,7 +196,7 @@ _ask_token() { # Check configuration is fine with user setting _validate_config() { - [[ $1 =~ ^(c|config|h|help|u|user|update|version) ]] && return 0 + [[ $1 =~ ^(c|config|h|help|u|user|update) ]] && return 0 if [[ -z $user ]]; then echo 'Hi fellow! To access your gists, I need your Github username' echo "Also a personal token with scope which allows \"gist\"!" @@ -215,7 +216,7 @@ _validate_config() { # Apply current configuration into config file _reformat_config() { - local line_token=$(sed -ne '/^token=/{p;q}' $CONFIG); line_token=${line_token:-token=} + local line_token=$(sed -ne '/^token=/h; ${x;p}' $CONFIG); line_token=${line_token:-token=$token} for key in ${VALID_CONFIGS[@]}; do [[ $key == token ]] && echo $line_token && continue # Because format may like this: token=$(COMMAND-TO-GET-TOKEN), just leave it untouched local value="${!key}"; local valid_values=${CONFIG_VALUES[$key]} @@ -892,7 +893,7 @@ case "$1" in _clean_repos ;; config | c) shift - _configure "$@" && { _apply_config && (_check_protocol &>/dev/null &); } ;; + _configure "$@" && _apply_config && sed -ne "/^$1=/p" $CONFIG && (_check_protocol &>/dev/null &) ;; user | u) shift _query_user "$@" ;; -- cgit v1.2.3-70-g09d2