From fbf8c1d3cf60bf620b1535a0af523ff23ae3a200 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Sat, 7 Dec 2024 03:38:14 +0200 Subject: new ak flag -v: prints version of ak and exits --- lib/_ak_script | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'lib/_ak_script') diff --git a/lib/_ak_script b/lib/_ak_script index 81da347..2338d1d 100755 --- a/lib/_ak_script +++ b/lib/_ak_script @@ -58,7 +58,27 @@ _ak_title_description(){ _ak_usage(){ _ak_title_description - _ak_help + _ak_help 2>&1 +} + +_ak_print_version(){ + git_repo="$(ls -l $AK_LIBDIR/_ak_script | cut -d '>' -f 2 | sed 's/^ //' | rev | cut -d '/' -f 3- | rev)" + patch_version="$(git --git-dir="${git_repo}/.git" -P log --reverse --oneline --decorate | tail -n 1 | cut -d ' ' -f 1)" + gtags="$(git --git-dir="${git_repo}/.git" -P tag | tail -n 1)" + if [ -f "$AK_WORKDIR/version" ] + then + cat $AK_WORKDIR/version + elif [ -n "${gtags}" ] + then + echo "${gtags}" + else + echo "v0.0.0-${patch_version}" + fi +} + +_ak_version(){ + printf '%s - ' "$PROGRAM" + _ak_print_version 2>&1 } _ak_not_implemented(){ -- cgit v1.2.3