diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2024-03-31 12:00:59 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2024-03-31 12:00:59 +0300 |
commit | e4f18be94261b39544ef3bc50321f6aedeb45bd6 (patch) | |
tree | 2c79daf0bdc91beb91846f00bb3d3f51236967cf /lib/_ak_script | |
parent | 23a61661f03c03a357ad8aa47ba3595fabe24de1 (diff) | |
download | arching-kaos-tools-e4f18be94261b39544ef3bc50321f6aedeb45bd6.tar.gz arching-kaos-tools-e4f18be94261b39544ef3bc50321f6aedeb45bd6.tar.bz2 arching-kaos-tools-e4f18be94261b39544ef3bc50321f6aedeb45bd6.zip |
huge refactor, might breaking things
Diffstat (limited to 'lib/_ak_script')
-rwxr-xr-x | lib/_ak_script | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/_ak_script b/lib/_ak_script new file mode 100755 index 0000000..543f597 --- /dev/null +++ b/lib/_ak_script @@ -0,0 +1,64 @@ +#!/bin/bash +source $AK_LIBDIR/_ak_log + +# Wanna talk about it? +_ak_new_line(){ + printf '\n' +} + +_ak_exit_program(){ +# Needs rework: +# cd $curdir +# if [ "$3" == "save_log" ] +# then +# tar cvfz $curdir/$(basename $tempdir)-$launch_timestamp.tgz $tempdir +# fi +# rm -rf $tempdir + if [ $1 -ne 0 ] + then + logit "ERROR" "$2 ($1)" + else + logit "EXIT" "$2" + fi + exit $1 +} + +_ak_help(){ + if [ ! -z $fullprogrampath ] && [ -n "$fullprogrampath" ] + then + cat $fullprogrampath |grep '^##'| sed 's/^##//g;s/^ //g' 1>&2 + exit 1 + else + logit "ERROR" "fullprogrampath was not set" + exit 1 + fi +} + +_ak_title_description(){ + + if [ ! -n "$descriptionString" ] + then + # Choose to exit with error to enforce standard + logit "ERROR" "No description string" + exit 1 + # Alternative solution + # full_title="$(printf '%s' "$PROGRAM")" + fi + + full_title="$(printf '%s - %s' "$PROGRAM" "$descriptionString")" + delimiter_count=`echo -n $full_title | wc -c` + ( + printf '%s' "$full_title" + _ak_new_line + while [ $delimiter_count -gt 0 ] + do + printf '=' + delimiter_count=$(($delimiter_count-1)) + done + _ak_new_line ) 1>&2 +} + +_ak_usage(){ + _ak_title_description + _ak_help +} |