diff options
author | typebrook <typebrook@gmail.com> | 2020-05-14 16:58:53 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2020-05-14 17:01:18 +0800 |
commit | 8124b6fd049d1b7fa19113fd0b117827ef6a00d8 (patch) | |
tree | 4731dc33234029aa68261db14e354ccce3e054d5 | |
parent | b4135ce0875e5cd5bfbb60897f73adefa57ee081 (diff) |
Refactor code
-rwxr-xr-x | gist | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -274,9 +274,9 @@ _validate_config() { | |||
274 | _apply_config() { | 274 | _apply_config() { |
275 | _validate_config "$@" || return 1 | 275 | _validate_config "$@" || return 1 |
276 | 276 | ||
277 | [[ -z $folder || ! -w $(dirname "$folder") ]] && folder=~/gist | 277 | [[ -z $folder || ! -w $(dirname "$folder") ]] && folder=~/gist; mkdir -p $folder |
278 | mkdir -p $folder | ||
279 | INDEX=$folder/index; [[ -e $INDEX ]] || touch $INDEX | 278 | INDEX=$folder/index; [[ -e $INDEX ]] || touch $INDEX |
279 | getConfiguredClient | ||
280 | } | 280 | } |
281 | 281 | ||
282 | # extract trailing hashtags from description | 282 | # extract trailing hashtags from description |
@@ -621,8 +621,7 @@ _show_detail() { | |||
621 | echo -e created_at: $created_at | 621 | echo -e created_at: $created_at |
622 | echo -e updated_at: $updated_at | 622 | echo -e updated_at: $updated_at |
623 | echo -e files: | 623 | echo -e files: |
624 | echo $file_array | tr ',' '\n' | tr '@' ' ' \ | 624 | tr ',' '\n' <<<${file_array//@/ } | column -t | sed -e 's/^/ /' |
625 | | column -t | sed -e 's/^/ /' | ||
626 | done | 625 | done |
627 | } | 626 | } |
628 | 627 | ||
@@ -752,8 +751,7 @@ _edit_gist() { | |||
752 | 751 | ||
753 | # Print helper message | 752 | # Print helper message |
754 | usage() { | 753 | usage() { |
755 | sed -E -n -e '/^#/ !q; 1,/^# --/ d; s/^# //p' "$0" \ | 754 | sed -Ene "/^#/ !q; 1,/^# --/ d; s/^# //p; s/^( *|Usage: )gist/\1$NAME/" "$0" |
756 | | sed -Ee "s/^( *|Usage: )gist/\1$NAME/" | ||
757 | } | 755 | } |
758 | 756 | ||
759 | # Check remote urls of all repos match current protocol in configuration file | 757 | # Check remote urls of all repos match current protocol in configuration file |
@@ -855,7 +853,6 @@ _access_last_index() { | |||
855 | } | 853 | } |
856 | 854 | ||
857 | _apply_config "$@" || exit 1 | 855 | _apply_config "$@" || exit 1 |
858 | getConfiguredClient || exit 1 | ||
859 | if [[ $init ]]; then _fetch_gists; exit 0; fi | 856 | if [[ $init ]]; then _fetch_gists; exit 0; fi |
860 | case "$1" in | 857 | case "$1" in |
861 | "") | 858 | "") |