Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
May 4, 2023
Merged

Conversation

LoneExile
Copy link
Contributor

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 LoneExile changed the title feat(update): add flag (-a, --all) #123 feat(update): add flag (-a, --all) May 3, 2023
@LoneExile
Copy link
Contributor Author

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; }

Copy link
Member

@mamaraddio mamaraddio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make it as suggested in #123

    [[ $1 = "self" ]] && { _pull $ZAP_DIR; return }
    [[ $1 = "all" ]] && { for _plug in ${ZAP_INSTALLED_PLUGINS[@]}; do _pull "$ZAP_PLUGIN_DIR/$_plug"; done; return }

Is more clear when you want to update all plugins to run zap update all instead of using --all option.
In addition the zap update self is useful for updating zap itself without entering the interactive menu (all doesn't update zap itself).

Lastly the return without value returns the status code of the last executed command.

@LoneExile
Copy link
Contributor Author

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!

@LoneExile LoneExile changed the title feat(update): add flag (-a, --all) feat(update): add flag (self, all) May 4, 2023
@mamaraddio mamaraddio merged commit 0f0bc99 into zap-zsh:master May 4, 2023
@mamaraddio
Copy link
Member

Thanks for your contribution @LoneExile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants