zap-zsh / zap

:zap: Zap is a minimal zsh plugin manager
https://www.zapzsh.com/
GNU General Public License v3.0
942 stars 33 forks source link

feat(update): add flag (self, all) #139

Closed LoneExile closed 1 year ago

LoneExile commented 1 year ago

I make some changes from #123

Please let me know if any changes or improvements are needed, and I'll be happy to make the necessary adjustments. Thank you for considering this contribution!

LoneExile commented 1 year ago

Do you think it would be better to check for out-of-date plugins and only show those that need to be updated?

    local _plugin _plug _status _out_of_date

    function _check() {
        git -C "$1" remote update &> /dev/null
        _out_of_date=false
        case $(LANG=en_US git -C "$1" status -uno | grep -Eo '(ahead|behind|up to date)') in
            ahead)
                _status='\033[1;34mLocal ahead remote\033[0m' ;;
            behind)
                _status='\033[1;33mOut of date\033[0m'
                _out_of_date=true ;;
            'up to date')
                _status='\033[1;32mUp to date\033[0m' ;;
            *)
                _status='\033[1;31mDiverged state\033[0m' ;;
        esac
    }

    [[ "$1" == "-a" || "$1" == "--all" ]] && { for _plug in ${ZAP_INSTALLED_PLUGINS[@]}; do _check "$ZAP_PLUGIN_DIR/$_plug"; $_out_of_date && _pull "$ZAP_PLUGIN_DIR/$_plug"; done; return; }
LoneExile commented 1 year ago

Hi! I have made the changes you requested in #123:

I've updated the _zap_update() function to support the self and all options as you suggested:

Using zap update self will now update Zap itself without entering the interactive menu. Using zap update all will update all plugins without the need for the --all option. Please note that all doesn't update Zap itself.

Please review the changes and let me know if you have any feedback. Thanks!

mamaraddio commented 1 year ago

Thanks for your contribution @LoneExile