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