aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-12-07 03:38:14 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-12-07 03:38:14 +0200
commitfbf8c1d3cf60bf620b1535a0af523ff23ae3a200 (patch)
tree6d11e3953d7cdf3f27a551d8f1e8908089ad6aca /lib
parent9cb9fda65b96cf851f47a3fb6ec57b8d51b710cd (diff)
downloadarching-kaos-tools-fbf8c1d3cf60bf620b1535a0af523ff23ae3a200.tar.gz
arching-kaos-tools-fbf8c1d3cf60bf620b1535a0af523ff23ae3a200.tar.bz2
arching-kaos-tools-fbf8c1d3cf60bf620b1535a0af523ff23ae3a200.zip
new ak flag -v: prints version of ak and exits
Diffstat (limited to 'lib')
-rwxr-xr-xlib/_ak_script22
1 files changed, 21 insertions, 1 deletions
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(){