aboutsummaryrefslogtreecommitdiff
path: root/lib/_ak_script
diff options
context:
space:
mode:
Diffstat (limited to 'lib/_ak_script')
-rwxr-xr-xlib/_ak_script64
1 files changed, 55 insertions, 9 deletions
diff --git a/lib/_ak_script b/lib/_ak_script
index a8c4be4..02741cb 100755
--- a/lib/_ak_script
+++ b/lib/_ak_script
@@ -17,7 +17,8 @@
### You should have received a copy of the GNU General Public License
### along with this program. If not, see <http://www.gnu.org/licenses/>.
###
-source ./lib/_ak_log > /dev/null 2>&1 || source $AK_LIBDIR/_ak_log > /dev/null 2>&1
+source ./lib/_ak_lib_load > /dev/null 2>&1 || source $AK_LIBDIR/_ak_lib_load > /dev/null 2>&1
+_ak_lib_load _ak_log
# Wanna talk about it?
function _ak_new_line(){
@@ -44,12 +45,7 @@ function _ak_exit_program(){
function _ak_help(){
if [ ! -z $fullprogrampath ] && [ -n "$fullprogrampath" ]
then
- cat $fullprogrampath | grep -v '^###' | grep '^##'| sed 's/^##//g;s/^ //g' >&2 #| \
- # cat | while read line
- # do
- # echo -n "$line" | xxd
- # _ak_log_info "$line"
- # done
+ cat $fullprogrampath | grep -v '^###' | grep '^##'| sed 's/^##//g;s/^ //g' >&2
exit 1
else
_ak_log_error "fullprogrampath was not set"
@@ -94,7 +90,7 @@ function _ak_usage(){
_ak_title_description 2>&1
_ak_license 2>&1
_ak_help 2>&1
- ) | sed 's/^/# /g' | while read line; do _ak_log_info "$line"; done
+ ) | sed 's/^/# /g' | while read line; do _ak_log_info "${line}"; done
}
function _ak_print_version(){
@@ -145,7 +141,7 @@ function _ak_make_temp_file(){
}
function _ak_check_and_create_dir(){
- if [ ! -d "$1" ]
+ if [ ! -z "$1" ] && [ -n "$1" ] && [ ! -d "$1" ]
then
mkdir -p "$1"
if [ $? -eq 0 ]
@@ -175,3 +171,53 @@ function _ak_let_there_be_file(){
_ak_log_debug "$1 file found"
fi
}
+
+function _ak_init_file_as_json_array(){
+ if [ ! -f "$1" ]
+ then
+ printf "[]" > $1
+ if [ $? -eq 0 ]
+ then
+ _ak_log_info "File $1 created!"
+ else
+ _ak_log_error "Problem occured while creating $1"
+ exit 1
+ fi
+ else
+ _ak_log_debug "$1 file found"
+ fi
+}
+
+function _ak_countdown_seconds(){
+ default_countdown=5
+ if [ ! -z "$1" ] && [ -n "$1" ]
+ then
+ if [ "$(echo -n $1 | sed -e 's/^[0-9]*$//g')" == "" ]
+ then
+ countdown=$1
+ else
+ countdown=${default_countdown}
+ fi
+ else
+ countdown=${default_countdown}
+ fi
+ printf " %s" "$countdown"
+ countdown="$(expr $countdown - 1)"
+ sleep 1
+ while [ $countdown -gt 0 ]
+ do
+ if [ $countdown -lt 10 ]
+ then
+ printf "\b\b %s" "$countdown"
+ else
+ printf "\b\b%s" "$countdown"
+ fi
+ countdown="$(expr $countdown - 1)"
+ sleep 1
+ done
+ printf "\b\b starting!!!"
+ sleep 1
+ printf "\n"
+}
+
+# _ak_log_debug "_ak_script loaded $(caller)"