helpers: Add --slient option to bash-it update

pull/1626/head
Noah Gorny 2020-06-19 17:56:09 +03:00
parent 9b208e7d5c
commit 4ca6dd9a36
1 changed files with 41 additions and 25 deletions

View File

@ -159,14 +159,29 @@ _bash-it_update-dev() {
_about 'updates Bash-it to the latest master'
_group 'lib'
_bash-it_update- dev
_bash-it_update- dev "$@"
}
_bash-it_update-stable() {
_about 'updates Bash-it to the latest tag'
_group 'lib'
_bash-it_update- stable
_bash-it_update- stable "$@"
}
_bash-it_pull_and_update_inner() {
git checkout "$1" &> /dev/null
if [[ $? -eq 0 ]]; then
echo "Bash-it successfully updated."
echo ""
echo "Migrating your installation to the latest $2 version now..."
_bash-it-migrate
echo ""
echo "All done, enjoy!"
bash-it reload
else
echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean."
fi
}
_bash-it_update-() {
@ -174,6 +189,12 @@ _bash-it_update-() {
_param '1: What kind of update to do (stable|dev)'
_group 'lib'
declare silent
for word in $@; do
if [[ ${word} == "--silent" || ${word} == "-s" ]]; then
silent=true
fi
done
local old_pwd="${PWD}"
cd "${BASH_IT}" || return
@ -215,21 +236,15 @@ _bash-it_update-() {
git log --format="%h: $description (%an)" -1 $i
done
echo ""
if [[ $silent ]]; then
echo "Updating to ${TARGET}($(git log -1 --format=%h "${TARGET}"))..."
_bash-it_pull_and_update_inner $TARGET $version
else
read -e -n 1 -p "Would you like to update to ${TARGET}($(git log -1 --format=%h "${TARGET}"))? [Y/n] " RESP
case $RESP in
[yY]|"")
git checkout "${TARGET}" &> /dev/null
if [[ $? -eq 0 ]]; then
echo "Bash-it successfully updated."
echo ""
echo "Migrating your installation to the latest $version version now..."
_bash-it-migrate
echo ""
echo "All done, enjoy!"
bash-it reload
else
echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean."
fi
_bash-it_pull_and_update_inner $TARGET $version
;;
[nN])
echo "Not upgrading…"
@ -238,6 +253,7 @@ _bash-it_update-() {
echo -e "\033[91mPlease choose y or n.\033[m"
;;
esac
fi
else
if [[ ${version} == "stable" ]]; then
echo "You're on the latest stable version. If you want to check out the latest 'dev' version, please run \"bash-it update dev\""