From 1853299eb102384452a241cd17e085f3e95d0fe2 Mon Sep 17 00:00:00 2001 From: kevin zhuang Date: Sun, 28 Jun 2020 09:21:44 +1000 Subject: [PATCH] feat(main): added version flag --- dotbare | 10 ++++++++-- scripts/fupgrade | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dotbare b/dotbare index 4921e3a..99660f2 100755 --- a/dotbare +++ b/dotbare @@ -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}" diff --git a/scripts/fupgrade b/scripts/fupgrade index fab1aaf..2538809 100755 --- a/scripts/fupgrade +++ b/scripts/fupgrade @@ -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