2
0
mirror of https://github.com/kazhala/dotbare synced 2024-11-04 06:00:45 +00:00

feat(main): added version flag

This commit is contained in:
kevin zhuang 2020-06-28 09:21:44 +10:00
parent bc98c7892e
commit 1853299eb1
2 changed files with 9 additions and 4 deletions

10
dotbare
View File

@ -24,7 +24,8 @@ function usage() {
echo -e "dotbare added couple useful scripts starting with 'f' prefix to help you"
echo -e "manage your interact with your git bare repo a little easier with the help of fzf\n"
echo -e "optional arguments:"
echo -e " -h\t\tshow this help message and exit"
echo -e " -h, --help\t\tshow this help message and exit"
echo -e " -v, --version\t\tshow dotbare current version"
echo -e "Available commands:"
echo -e " Any git commands, treat dotbare as git"
echo -e " fadd \t\tstage modified file interactively"
@ -56,10 +57,15 @@ fi
exit 1
case "$1" in
help|-h)
--help|-h)
usage
exit 0
;;
-v|--version)
cd "${mydir}"
printf "Current dotbare version: %s\n" "$(git describe --tags $(git rev-list --tags --max-count=1))"
exit 0
;;
*)
if [[ -x "${mydir}/scripts/$1" ]]; then
exec "${mydir}/scripts/$1" "${@:2}"

View File

@ -2,7 +2,6 @@
#
# update dotbare to latest master
set -e
set -f
mydir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@ -39,7 +38,7 @@ cd "${mydir}/.."
echo "Updating dotbare ..."
if git pull --rebase --stat origin master; then
echo "dotbare updated successfully"
printf "Current dotbare version: %s\n" $(git describe --tags $(git rev-list --tags --max-count=1))
printf "Current dotbare version: %s\n" "$(git describe --tags $(git rev-list --tags --max-count=1))"
else
echo "Something went wrong, please try again or fire up a issue at https://github.com/kazhala/dotbare"
fi