aboutsummaryrefslogtreecommitdiff
path: root/bin/ak
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-03-02 01:51:33 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-03-02 01:51:33 +0200
commitb11434ed1255f3c6a967be093e6e193780bc7ed5 (patch)
tree8c13fac7814010daa85ebb5c55e3b18d02811e8e /bin/ak
parenta506f0a48e02587f59bbd24f67812416a7a74038 (diff)
downloadarching-kaos-tools-b11434ed1255f3c6a967be093e6e193780bc7ed5.tar.gz
arching-kaos-tools-b11434ed1255f3c6a967be093e6e193780bc7ed5.tar.bz2
arching-kaos-tools-b11434ed1255f3c6a967be093e6e193780bc7ed5.zip
Removed old ak-cli approach in favor of ak
Instead of hardcoding things in a big script we simply search in ak's arguments for appropriate scripts and past the rest of values as arguments to the script found. Running with no arguments *will* be printing all available scripts with --help flag to provide a good overview.
Diffstat (limited to 'bin/ak')
-rwxr-xr-xbin/ak51
1 files changed, 51 insertions, 0 deletions
diff --git a/bin/ak b/bin/ak
new file mode 100755
index 0000000..6a4fc01
--- /dev/null
+++ b/bin/ak
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+PROGRAM=$(basename $0)
+
+logit(){
+ ak-logthis "$PROGRAM" "$1" "$2"
+}
+
+if [ $# -eq 0 ]
+then
+ logit "WARNING" "No command given"
+ (
+ find $AK_BINDIR | grep 'ak-' | while read available
+ do
+ #subcmd="$(basename $available | cut -d '-' -f 2)"
+ subcmd="$(basename $available)"
+ args="-h"
+ if [ -n "$subcmd" ]
+ then
+ echo $subcmd
+ # $(echo $subcmd) $args
+ fi
+ done
+ ) | sort | uniq
+ exit 1
+fi
+
+subcmd="$(echo $* | sed -e 's/ /-/g')"
+if [ -f "$AK_BINDIR/ak-$subcmd" ]
+then
+ $(echo ak-$subcmd)
+ exit $?
+else
+ argc=$#
+ argv="$*"
+ counter=1
+ while [ $counter -lt $argc ]
+ do
+ subcmd="$(echo $argv | cut -d ' ' -f -$counter | sed -e 's/ /\-/g')"
+ args="$(echo "$argv"| cut -d ' ' -f $(($counter + 1))-)"
+ if [ -n "$subcmd" ] && [ -f "$AK_BINDIR/ak-$subcmd" ]
+ then
+ logit "INFO" "Running: ak-$subcmd with args: $args"
+ $(echo ak-$subcmd) $args
+ exit $?
+ fi
+ counter=$(($counter + 1))
+ done
+ logit "ERROR" "Unknown subcommand: $*"
+ exit 1
+fi