diff options
| author | typebrook <typebrook@gmail.com> | 2020-03-19 13:48:49 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-03-19 17:42:17 +0800 |
| commit | f1ad5ae584ec7458f56927b0aaba5cf8c833cf64 (patch) | |
| tree | 2445d43b7701074978f4eb0ce34d7e96aea18ff2 | |
| parent | 177ea6791f73c204932fbd4d276a5b63e2aab95f (diff) | |
Add new subcommand 'gist pin'
| -rwxr-xr-x | gist | 28 |
1 files changed, 26 insertions, 2 deletions
| @@ -39,6 +39,7 @@ | |||
| 39 | # Since now a gist is a local cloned repo | 39 | # Since now a gist is a local cloned repo |
| 40 | # It is your business to do git commit and git push | 40 | # It is your business to do git commit and git push |
| 41 | 41 | ||
| 42 | # TODO color pinned tags | ||
| 42 | # TODO README/helper message about tag and default action ${SHELL:-bash} | 43 | # TODO README/helper message about tag and default action ${SHELL:-bash} |
| 43 | # TODO codebase statistics, like C++ or something | 44 | # TODO codebase statistics, like C++ or something |
| 44 | # TODO migrate to gh-page, with install.sh and check_md5 in README | 45 | # TODO migrate to gh-page, with install.sh and check_md5 in README |
| @@ -678,6 +679,26 @@ _show_tags() { | |||
| 678 | _hashtags "$description" | tr ' ' '\n' | sed -e '/^$/d' | 679 | _hashtags "$description" | tr ' ' '\n' | sed -e '/^$/d' |
| 679 | done < $INDEX \ | 680 | done < $INDEX \ |
| 680 | | sort -u | 681 | | sort -u |
| 682 | |||
| 683 | tags=( $pin ) | ||
| 684 | echo | ||
| 685 | echo Pinned tags: ${tags[@]/#/#} | ||
| 686 | } | ||
| 687 | |||
| 688 | # pin/unpin tags | ||
| 689 | _pin_tags() { | ||
| 690 | local new_pinned=( $(echo $pin $* | tr ' ' '\n' | sort | uniq -u | xargs) ) | ||
| 691 | for tag in ${new_pinned[@]}; do | ||
| 692 | if _gist_id $tag &> /dev/null; then | ||
| 693 | echo Invalid tag: $tag | ||
| 694 | return 1 | ||
| 695 | fi | ||
| 696 | done || exit 1 | ||
| 697 | |||
| 698 | hint=false _tag_gist ${new_pinned[@]} | ||
| 699 | echo > /dev/tty | ||
| 700 | echo Pinned tags: ${new_pinned[@]/#/#} > /dev/tty | ||
| 701 | sed -i'' -e "/^pin=/ d" "$CONFIG" && echo pin=\'"${new_pinned[@]}"\' >> "$CONFIG" | ||
| 681 | } | 702 | } |
| 682 | 703 | ||
| 683 | _apply_config "$@" || exit 1 | 704 | _apply_config "$@" || exit 1 |
| @@ -718,14 +739,17 @@ case "$1" in | |||
| 718 | github | G) | 739 | github | G) |
| 719 | shift | 740 | shift |
| 720 | _import_to_github "$1" ;; | 741 | _import_to_github "$1" ;; |
| 721 | push | p) | 742 | push | P) |
| 722 | shift | 743 | shift |
| 723 | _push_to_remote "$1" ;; | 744 | _push_to_remote "$1" ;; |
| 724 | tag | t) | 745 | tag | t) |
| 725 | shift | 746 | shift |
| 726 | _tag_gist "$@" ;; | 747 | _tag_gist "$@" ;; |
| 727 | tags) | 748 | tags | tt) |
| 728 | _show_tags ;; | 749 | _show_tags ;; |
| 750 | pin | p) | ||
| 751 | shift | ||
| 752 | _pin_tags "$@" ;; | ||
| 729 | version) | 753 | version) |
| 730 | echo "Version $currentVersion" ;; | 754 | echo "Version $currentVersion" ;; |
| 731 | update) | 755 | update) |