aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-03-27 03:40:07 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-03-27 03:40:07 +0200
commit5c08911132823735801aa70a4e2a23bc3f1c859a (patch)
tree17dc9ca8c8c2958cc8323484b1e9df1bd1630569
parent5ad0e143e7f76c740defe6d983e4c54007a23b25 (diff)
downloadarching-kaos-tools-5c08911132823735801aa70a4e2a23bc3f1c859a.tar.gz
arching-kaos-tools-5c08911132823735801aa70a4e2a23bc3f1c859a.tar.bz2
arching-kaos-tools-5c08911132823735801aa70a4e2a23bc3f1c859a.zip
Moving stuff to lib
-rwxr-xr-xbin/ak5
-rwxr-xr-xbin/ak-categories12
-rwxr-xr-xlib/_ak_newline5
-rwxr-xr-xlib/_ak_script_description16
-rwxr-xr-xlib/_ak_script_exit17
5 files changed, 49 insertions, 6 deletions
diff --git a/bin/ak b/bin/ak
index 056a6a3..d18012a 100755
--- a/bin/ak
+++ b/bin/ak
@@ -2,6 +2,7 @@
PROGRAM=$(basename $0)
source $AK_LIBDIR/_ak_logit
+source $AK_LIBDIR/_ak_script_exit
if [ $# -eq 0 ]
then
@@ -26,7 +27,7 @@ subcmd="$(echo $* | sed -e 's/ /-/g')"
if [ -f "$AK_BINDIR/ak-$subcmd" ]
then
$(echo ak-$subcmd)
- exit $?
+ exit_program $? "ak-$subcmd command finished";
else
argc=$#
argv="$*"
@@ -39,7 +40,7 @@ else
then
logit "INFO" "Running: ak-$subcmd with args: $args"
$(echo ak-$subcmd) $args
- exit $?
+ exit_program $? "ak-$subcmd command finished";
fi
counter=$(($counter + 1))
done
diff --git a/bin/ak-categories b/bin/ak-categories
index 292e789..8750159 100755
--- a/bin/ak-categories
+++ b/bin/ak-categories
@@ -1,8 +1,10 @@
#!/bin/bash
AK_CATEGORIES="$AK_WORKDIR/categories"
PROGRAM="$(basename $0)"
+descriptionString="A module for adding and refering zblocks to categories"
source $AK_LIBDIR/_ak_logit
+source $AK_LIBDIR/_ak_script_description
if [ ! -d $AK_CATEGORIES ]; then
mkdir $AK_CATEGORIES
@@ -38,7 +40,7 @@ _ak_modules_categories_index(){
done
}
_ak_modules_categories_title(){
- echo "$PROGRAM"
+ description
}
_ak_modules_categories_import(){
@@ -85,19 +87,21 @@ _ak_modules_categories_add(){
}
EOF
else
- echo "File $FILE doesn't exist";
+ logit "ERROR" "File $FILE doesn't exist";
exit 2
fi
ak-zblock-pack "news/add" $(pwd)/data
if [ $? == 0 ]
then
- echo "News added successfully"
+ logit "INFO" "News added successfully"
else
- echo "error??"
+ logit "ERROR" "error??"
exit 1
fi
}
+
_ak_modules_categories_usage(){
+ _ak_modules_categories_title
echo " -h, --help Prints this help message"
echo " index Prints an indexed table of your news files"
echo " import <file> #TODO"
diff --git a/lib/_ak_newline b/lib/_ak_newline
new file mode 100755
index 0000000..955ee6c
--- /dev/null
+++ b/lib/_ak_newline
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+new_line(){
+ printf '\n'
+}
diff --git a/lib/_ak_script_description b/lib/_ak_script_description
new file mode 100755
index 0000000..740b1c4
--- /dev/null
+++ b/lib/_ak_script_description
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+source $AK_LIBDIR/_ak_newline
+
+description(){
+ full_title="$(printf '%s - %s' "$PROGRAM" "$descriptionString")"
+ delimiter_count=`echo -n $full_title | wc -c`
+ printf '%s' "$full_title"
+ new_line
+ while [ $delimiter_count -gt 0 ]
+ do
+ printf '='
+ delimiter_count=$(($delimiter_count-1))
+ done
+ new_line
+}
diff --git a/lib/_ak_script_exit b/lib/_ak_script_exit
new file mode 100755
index 0000000..81fe2c8
--- /dev/null
+++ b/lib/_ak_script_exit
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+exit_program(){
+# 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 "EXIT" "$2 ($1)"
+ else
+ logit "EXIT" "$2"
+ fi
+ exit $1
+}